diff --git a/Cargo.lock b/Cargo.lock index 075352fe..1c04abe4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4795,7 +4795,6 @@ dependencies = [ "chrono", "httpsign", "jrd", - "mdhtml", "nodeinfo", "openssl", "regex", diff --git a/web/src/actors/follow.rs b/web/src/actors/follow.rs index d629937b..50432e16 100644 --- a/web/src/actors/follow.rs +++ b/web/src/actors/follow.rs @@ -10,7 +10,7 @@ use apb::Collection; pub fn FollowList(outgoing: bool) -> impl IntoView { let follow___ = if outgoing { "following" } else { "followers" }; let symbol = if outgoing { "👥" } else { "📢" }; - let params = use_params::(); + let params = use_params::(); let auth = use_context::().expect("missing auth context"); let resource = create_local_resource( move || params.get().ok().and_then(|x| x.id).unwrap_or_default(), diff --git a/web/src/actors/header.rs b/web/src/actors/header.rs index 4baf4330..2144ba4a 100644 --- a/web/src/actors/header.rs +++ b/web/src/actors/header.rs @@ -6,7 +6,7 @@ use apb::{field::OptionalString, ActivityMut, Actor, Base, Object, ObjectMut}; #[component] pub fn ActorHeader() -> impl IntoView { - let params = use_params::(); + let params = use_params::(); let auth = use_context::().expect("missing auth context"); let actor = create_local_resource( move || params.get().ok().and_then(|x| x.id).unwrap_or_default(), diff --git a/web/src/actors/mod.rs b/web/src/actors/mod.rs index 9b947c05..72272392 100644 --- a/web/src/actors/mod.rs +++ b/web/src/actors/mod.rs @@ -1,9 +1,3 @@ pub mod follow; pub mod posts; pub mod header; - -use leptos_router::Params; // TODO can i remove this? -#[derive(Clone, leptos::Params, PartialEq)] -struct IdParam { - id: Option, -} diff --git a/web/src/actors/posts.rs b/web/src/actors/posts.rs index e35941e2..5e31f29a 100644 --- a/web/src/actors/posts.rs +++ b/web/src/actors/posts.rs @@ -5,7 +5,7 @@ use crate::prelude::*; #[component] pub fn ActorPosts() -> impl IntoView { let feeds = use_context::().expect("missing feeds context"); - let params = use_params::(); + let params = use_params::(); Signal::derive(move || { let id = params.get_untracked().ok().and_then(|x| x.id).unwrap_or_default(); let tl_url = format!("{}/outbox/page", Uri::api(U::Actor, &id, false)); diff --git a/web/src/app.rs b/web/src/app.rs index 18854686..16fc2da7 100644 --- a/web/src/app.rs +++ b/web/src/app.rs @@ -14,6 +14,7 @@ pub struct Feeds { pub user: Timeline, pub server: Timeline, pub context: Timeline, + pub tag: Timeline, } impl Feeds { @@ -24,6 +25,7 @@ impl Feeds { global: Timeline::new(format!("{URL_BASE}/inbox/page")), user: Timeline::new(format!("{URL_BASE}/actors/{username}/outbox/page")), server: Timeline::new(format!("{URL_BASE}/outbox/page")), + tag: Timeline::new(format!("{URL_BASE}/tags/upub/page")), context: Timeline::new(format!("{URL_BASE}/outbox/page")), // TODO ehhh } } @@ -35,6 +37,7 @@ impl Feeds { self.user.reset(None); self.server.reset(None); self.context.reset(None); + self.tag.reset(None); } } @@ -131,6 +134,8 @@ pub fn App() -> impl IntoView { } /> + } /> + // } /> @@ -194,6 +199,7 @@ fn Scrollable() -> impl IntoView { out }, }, + Some("tags") => format!("tags :: {}", path_iter.next().unwrap_or_default()), Some(p) => p.to_string(), None => "?".to_string(), } diff --git a/web/src/lib.rs b/web/src/lib.rs index cb059e0d..c9cb58ec 100644 --- a/web/src/lib.rs +++ b/web/src/lib.rs @@ -157,6 +157,11 @@ impl DashmapCache { } } +use leptos_router::Params; // TODO can i remove this? +#[derive(Clone, leptos::Params, PartialEq)] +pub struct IdParam { + id: Option, +} pub struct Http; diff --git a/web/src/prelude.rs b/web/src/prelude.rs index 9f6e85f7..a452fd8b 100644 --- a/web/src/prelude.rs +++ b/web/src/prelude.rs @@ -1,6 +1,7 @@ pub use crate::{ URL_BASE, Http, Uri, + IdParam, Cache, cache, // TODO move Cache under cache app::{Feeds, Loader}, auth::Auth, @@ -21,7 +22,7 @@ pub use crate::{ }, timeline::{ Timeline, - feed::Feed, + feed::{Feed, HashtagFeed}, thread::Thread, }, }; diff --git a/web/src/timeline/feed.rs b/web/src/timeline/feed.rs index 117c3ac8..cf3e0036 100644 --- a/web/src/timeline/feed.rs +++ b/web/src/timeline/feed.rs @@ -1,4 +1,5 @@ use leptos::*; +use leptos_router::use_params; use crate::prelude::*; use super::Timeline; @@ -33,3 +34,24 @@ pub fn Feed(tl: Timeline) -> impl IntoView { {move || if tl.loading.get() { Some(view! { }) } else { None }} } } + +#[component] +pub fn HashtagFeed(tl: Timeline) -> impl IntoView { + let params = use_params::(); + Signal::derive(move || { + let current_tag = tl.next.get_untracked() + .split('/') + .last() + .unwrap_or_default() + .split('?') + .next() + .unwrap_or_default() + .to_string(); + let new_tag = params.get().ok().and_then(|x| x.id).unwrap_or_default(); + if new_tag != current_tag { + tl.reset(Some(Uri::api(U::Hashtag, &new_tag, false))); + } + }).track(); + + view! { } +}