forked from alemi/upub
feat(web): hashtags timeline page
rather jank, literally hotglued on other feeds but eh it works for now ig?
This commit is contained in:
parent
2836ec2b37
commit
8ab39bfb2b
9 changed files with 38 additions and 11 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -4795,7 +4795,6 @@ dependencies = [
|
|||
"chrono",
|
||||
"httpsign",
|
||||
"jrd",
|
||||
"mdhtml",
|
||||
"nodeinfo",
|
||||
"openssl",
|
||||
"regex",
|
||||
|
|
|
@ -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::<super::IdParam>();
|
||||
let params = use_params::<IdParam>();
|
||||
let auth = use_context::<Auth>().expect("missing auth context");
|
||||
let resource = create_local_resource(
|
||||
move || params.get().ok().and_then(|x| x.id).unwrap_or_default(),
|
||||
|
|
|
@ -6,7 +6,7 @@ use apb::{field::OptionalString, ActivityMut, Actor, Base, Object, ObjectMut};
|
|||
|
||||
#[component]
|
||||
pub fn ActorHeader() -> impl IntoView {
|
||||
let params = use_params::<super::IdParam>();
|
||||
let params = use_params::<IdParam>();
|
||||
let auth = use_context::<Auth>().expect("missing auth context");
|
||||
let actor = create_local_resource(
|
||||
move || params.get().ok().and_then(|x| x.id).unwrap_or_default(),
|
||||
|
|
|
@ -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<String>,
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ use crate::prelude::*;
|
|||
#[component]
|
||||
pub fn ActorPosts() -> impl IntoView {
|
||||
let feeds = use_context::<Feeds>().expect("missing feeds context");
|
||||
let params = use_params::<super::IdParam>();
|
||||
let params = use_params::<IdParam>();
|
||||
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));
|
||||
|
|
|
@ -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 {
|
|||
<Route path="followers" view=move || view! { <FollowList outgoing=false /> } />
|
||||
</Route>
|
||||
|
||||
<Route path="tags/:id" view=move || view! { <HashtagFeed tl=feeds.tag /> } />
|
||||
|
||||
<Route path="objects/:id" view=ObjectView />
|
||||
// <Route path="/web/activities/:id" view=move || view! { <ActivityPage tl=context_tl /> } />
|
||||
|
||||
|
@ -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(),
|
||||
}
|
||||
|
|
|
@ -157,6 +157,11 @@ impl DashmapCache<String> {
|
|||
}
|
||||
}
|
||||
|
||||
use leptos_router::Params; // TODO can i remove this?
|
||||
#[derive(Clone, leptos::Params, PartialEq)]
|
||||
pub struct IdParam {
|
||||
id: Option<String>,
|
||||
}
|
||||
|
||||
pub struct Http;
|
||||
|
||||
|
|
|
@ -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,
|
||||
},
|
||||
};
|
||||
|
|
|
@ -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! { <Loader /> }) } else { None }}
|
||||
}
|
||||
}
|
||||
|
||||
#[component]
|
||||
pub fn HashtagFeed(tl: Timeline) -> impl IntoView {
|
||||
let params = use_params::<IdParam>();
|
||||
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! { <Feed tl=tl /> }
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue