forked from alemi/upub
feat(web): button to refresh feeds
This commit is contained in:
parent
e6e13e95da
commit
e79061c294
2 changed files with 32 additions and 0 deletions
|
@ -160,6 +160,25 @@ pub fn App() -> impl IntoView {
|
||||||
#[component]
|
#[component]
|
||||||
fn Scrollable() -> impl IntoView {
|
fn Scrollable() -> impl IntoView {
|
||||||
let location = use_location();
|
let location = use_location();
|
||||||
|
let feeds = use_context::<Feeds>().expect("missing feeds context");
|
||||||
|
let relevant_timeline = Signal::derive(move || {
|
||||||
|
let path = location.pathname.get();
|
||||||
|
if path.contains("/web/home") {
|
||||||
|
Some(feeds.home)
|
||||||
|
} else if path.contains("/web/server") {
|
||||||
|
Some(feeds.global)
|
||||||
|
} else if path.starts_with("/web/local") {
|
||||||
|
Some(feeds.server)
|
||||||
|
} else if path.starts_with("/web/inbox") {
|
||||||
|
Some(feeds.private)
|
||||||
|
} else if path.starts_with("/web/actors") {
|
||||||
|
Some(feeds.user)
|
||||||
|
} else if path.starts_with("/web/objects") {
|
||||||
|
Some(feeds.context)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
});
|
||||||
let breadcrumb = Signal::derive(move || {
|
let breadcrumb = Signal::derive(move || {
|
||||||
let path = location.pathname.get();
|
let path = location.pathname.get();
|
||||||
let mut path_iter = path.split('/').skip(2);
|
let mut path_iter = path.split('/').skip(2);
|
||||||
|
@ -193,6 +212,9 @@ fn Scrollable() -> impl IntoView {
|
||||||
<div class="tl-header w-100 center mb-1">
|
<div class="tl-header w-100 center mb-1">
|
||||||
<a class="breadcrumb mr-1" href="javascript:history.back()" ><b>"<<"</b></a>
|
<a class="breadcrumb mr-1" href="javascript:history.back()" ><b>"<<"</b></a>
|
||||||
<b>{crate::NAME}</b>" :: "{breadcrumb}
|
<b>{crate::NAME}</b>" :: "{breadcrumb}
|
||||||
|
{move || relevant_timeline.get().map(|tl| view! {
|
||||||
|
<a class="breadcrumb ml-1" href="#" on:click=move|_| tl.refresh() ><span class="emoji">"♻️"</span></a>
|
||||||
|
})}
|
||||||
</div>
|
</div>
|
||||||
<Outlet />
|
<Outlet />
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -40,6 +40,16 @@ impl Timeline {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn refresh(&self) {
|
||||||
|
self.reset(
|
||||||
|
self.next
|
||||||
|
.get_untracked()
|
||||||
|
.split('?')
|
||||||
|
.next()
|
||||||
|
.map(|x| x.to_string())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn spawn_more(&self, auth: Auth) {
|
pub fn spawn_more(&self, auth: Auth) {
|
||||||
let _self = *self;
|
let _self = *self;
|
||||||
spawn_local(async move {
|
spawn_local(async move {
|
||||||
|
|
Loading…
Reference in a new issue