From 8ab39bfb2b58fc5b87b5c55dac2c7bc786096770 Mon Sep 17 00:00:00 2001 From: alemi Date: Thu, 4 Jul 2024 03:14:26 +0200 Subject: [PATCH] feat(web): hashtags timeline page rather jank, literally hotglued on other feeds but eh it works for now ig? --- Cargo.lock | 1 - web/src/actors/follow.rs | 2 +- web/src/actors/header.rs | 2 +- web/src/actors/mod.rs | 6 ------ web/src/actors/posts.rs | 2 +- web/src/app.rs | 6 ++++++ web/src/lib.rs | 5 +++++ web/src/prelude.rs | 3 ++- web/src/timeline/feed.rs | 22 ++++++++++++++++++++++ 9 files changed, 38 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 075352f..1c04abe 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 d629937..50432e1 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 4baf433..2144ba4 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 9b947c0..7227239 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 e35941e..5e31f29 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 1885468..16fc2da 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 cb059e0..c9cb58e 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 9f6e85f..a452fd8 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 117c3ac..cf3e003 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! { } +}