diff --git a/web/src/app.rs b/web/src/app.rs index 3807953..19ab0e5 100644 --- a/web/src/app.rs +++ b/web/src/app.rs @@ -193,6 +193,7 @@ fn Scrollable() -> impl IntoView { let location = use_location(); let feeds = use_context::().expect("missing feeds context"); let auth = use_context::().expect("missing auth context"); + let config = use_context::>().expect("missing config context"); let relevant_timeline = Signal::derive(move || { let path = location.pathname.get(); if path.contains("/web/home") { @@ -246,7 +247,7 @@ fn Scrollable() -> impl IntoView { "<<" {crate::NAME}" :: "{breadcrumb} {move || relevant_timeline.get().map(|tl| view! { - "↺" + "↺" })} diff --git a/web/src/components/login.rs b/web/src/components/login.rs index d3e271b..cc43073 100644 --- a/web/src/components/login.rs +++ b/web/src/components/login.rs @@ -7,6 +7,7 @@ pub fn LoginBox( userid_tx: WriteSignal>, ) -> impl IntoView { let auth = use_context::().expect("missing auth context"); + let config = use_context::>().expect("missing config context"); let username_ref: NodeRef = create_node_ref(); let password_ref: NodeRef = create_node_ref(); let feeds = use_context::().expect("missing feeds context"); @@ -17,8 +18,8 @@ pub fn LoginBox(
@@ -45,14 +46,14 @@ pub fn LoginBox( token_tx.set(Some(auth_response.token)); // reset home feed and point it to our user's inbox feeds.home.reset(Some(format!("{URL_BASE}/actors/{username}/inbox/page"))); - feeds.home.spawn_more(auth); + feeds.home.spawn_more(auth, config); feeds.notifications.reset(Some(format!("{URL_BASE}/actors/{username}/notifications/page"))); - feeds.notifications.spawn_more(auth); + feeds.notifications.spawn_more(auth, config); // reset server feed: there may be more content now that we're authed feeds.global.reset(Some(format!("{URL_BASE}/inbox/page"))); - feeds.global.spawn_more(auth); + feeds.global.spawn_more(auth, config); feeds.server.reset(Some(format!("{URL_BASE}/outbox/page"))); - feeds.server.spawn_more(auth); + feeds.server.spawn_more(auth, config); }); } > diff --git a/web/src/page/config.rs b/web/src/page/config.rs index ec9d1bc..23aa837 100644 --- a/web/src/page/config.rs +++ b/web/src/page/config.rs @@ -6,6 +6,7 @@ use crate::{prelude::*, DEFAULT_COLOR}; pub fn ConfigPage(setter: WriteSignal) -> impl IntoView { let config = use_context::>().expect("missing config context"); let auth = use_context::().expect("missing auth context"); + let feeds = use_context::().expect("missing feeds context"); let (color, set_color) = leptos_use::use_css_var("--accent"); let (_color_rgb, set_color_rgb) = leptos_use::use_css_var("--accent-rgb"); @@ -97,7 +98,12 @@ pub fn ConfigPage(setter: WriteSignal) -> impl IntoView {

filters

    -
  • " replies"
  • +
  • " replies"
  • " likes"
  • " creates"
  • " updates"
  • diff --git a/web/src/timeline/feed.rs b/web/src/timeline/feed.rs index 4873bff..10308c5 100644 --- a/web/src/timeline/feed.rs +++ b/web/src/timeline/feed.rs @@ -10,10 +10,11 @@ pub fn Feed( ignore_filters: bool, ) -> impl IntoView { let auth = use_context::().expect("missing auth context"); + let config = use_context::>().expect("missing config context"); if let Some(auto_scroll) = use_context::>() { let _ = leptos::watch( move || auto_scroll.get(), - move |at_end, _, _| if *at_end { tl.spawn_more(auth) }, + move |at_end, _, _| if *at_end { tl.spawn_more(auth, config) }, true, ); } diff --git a/web/src/timeline/mod.rs b/web/src/timeline/mod.rs index ccfe02c..10ef395 100644 --- a/web/src/timeline/mod.rs +++ b/web/src/timeline/mod.rs @@ -40,7 +40,7 @@ impl Timeline { } } - pub fn refresh(&self, auth: Auth) { + pub fn refresh(&self, auth: Auth, config: Signal) { self.reset( self.next .get_untracked() @@ -48,13 +48,13 @@ impl Timeline { .next() .map(|x| x.to_string()) ); - self.spawn_more(auth); + self.spawn_more(auth, config); } - pub fn spawn_more(&self, auth: Auth) { + pub fn spawn_more(&self, auth: Auth, config: Signal) { let _self = *self; spawn_local(async move { - _self.more(auth).await + _self.more(auth, config).await }); } @@ -62,21 +62,28 @@ impl Timeline { self.loading.get_untracked() } - pub async fn more(&self, auth: Auth) { + pub async fn more(&self, auth: Auth, config: Signal) { if self.loading.get_untracked() { return } if self.over.get_untracked() { return } self.loading.set(true); - let res = self.load_more(auth).await; + let res = self.load_more(auth, config).await; self.loading.set(false); if let Err(e) = res { tracing::error!("failed loading posts for timeline: {e}"); } } - pub async fn load_more(&self, auth: Auth) -> reqwest::Result<()> { + pub async fn load_more(&self, auth: Auth, config: Signal) -> reqwest::Result<()> { use apb::{Collection, CollectionPage}; - let feed_url = self.next.get_untracked(); + let mut feed_url = self.next.get_untracked(); + if !config.get_untracked().filters.replies { + feed_url = if feed_url.contains('?') { + feed_url + "&replies=false" + } else { + feed_url + "?replies=false" + }; + } let collection : serde_json::Value = Http::fetch(&feed_url, auth).await?; let activities : Vec = collection .ordered_items() diff --git a/web/src/timeline/thread.rs b/web/src/timeline/thread.rs index eafb801..2eb650b 100644 --- a/web/src/timeline/thread.rs +++ b/web/src/timeline/thread.rs @@ -6,14 +6,15 @@ use super::Timeline; #[component] pub fn Thread(tl: Timeline, root: String) -> impl IntoView { let auth = use_context::().expect("missing auth context"); + let config = use_context::>().expect("missing config context"); if let Some(auto_scroll) = use_context::>() { let _ = leptos::watch( move || auto_scroll.get(), move |new, old, _| { match old { - None => tl.spawn_more(auth), // always do it first time + None => tl.spawn_more(auth, config), // always do it first time Some(old) => if *new && new != old { - tl.spawn_more(auth); + tl.spawn_more(auth, config); }, } },