fix(web): use create_effect rather than signal.track

This commit is contained in:
əlemi 2024-07-06 04:54:22 +02:00
parent 692ae7f31d
commit fb02be2f44
Signed by: alemi
GPG key ID: A4895B84D311642C
2 changed files with 5 additions and 6 deletions

View file

@ -6,14 +6,13 @@ use crate::prelude::*;
pub fn ActorPosts() -> impl IntoView { pub fn ActorPosts() -> impl IntoView {
let feeds = use_context::<Feeds>().expect("missing feeds context"); let feeds = use_context::<Feeds>().expect("missing feeds context");
let params = use_params::<IdParam>(); let params = use_params::<IdParam>();
Signal::derive(move || { create_effect(move |_| {
let id = params.get_untracked().ok().and_then(|x| x.id).unwrap_or_default(); let id = params.get().ok().and_then(|x| x.id).unwrap_or_default();
let tl_url = format!("{}/outbox/page", Uri::api(U::Actor, &id, false)); let tl_url = format!("{}/outbox/page", Uri::api(U::Actor, &id, false));
if !feeds.user.next.get_untracked().starts_with(&tl_url) { if !feeds.user.next.get_untracked().starts_with(&tl_url) {
feeds.user.reset(Some(tl_url)); feeds.user.reset(Some(tl_url));
} }
id });
}).track();
view! { view! {
<code class="cw color center mt-1 mb-1 ml-3 mr-3"> <code class="cw color center mt-1 mb-1 ml-3 mr-3">
<span class="emoji">"🖂"</span>" "<b>posts</b> <span class="emoji">"🖂"</span>" "<b>posts</b>

View file

@ -38,7 +38,7 @@ pub fn Feed(tl: Timeline) -> impl IntoView {
#[component] #[component]
pub fn HashtagFeed(tl: Timeline) -> impl IntoView { pub fn HashtagFeed(tl: Timeline) -> impl IntoView {
let params = use_params::<IdParam>(); let params = use_params::<IdParam>();
Signal::derive(move || { create_effect(move |_| {
let current_tag = tl.next.get_untracked() let current_tag = tl.next.get_untracked()
.split('/') .split('/')
.last() .last()
@ -51,7 +51,7 @@ pub fn HashtagFeed(tl: Timeline) -> impl IntoView {
if new_tag != current_tag { if new_tag != current_tag {
tl.reset(Some(Uri::api(U::Hashtag, &format!("{new_tag}/page"), false))); tl.reset(Some(Uri::api(U::Hashtag, &format!("{new_tag}/page"), false)));
} }
}).track(); });
view! { <Feed tl=tl /> } view! { <Feed tl=tl /> }
} }