Compare commits
No commits in common. "42ae2633f2dd2624a0c974e539234a0dd186a539" and "3db892f0386de41dd930f1738f031029c497e7d4" have entirely different histories.
42ae2633f2
...
3db892f038
6 changed files with 30 additions and 17 deletions
|
@ -105,7 +105,6 @@ pub fn ActorHeader() -> impl IntoView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused)]
|
|
||||||
async fn send_follow_response(kind: apb::ActivityType, target: String, to: String, auth: Auth) {
|
async fn send_follow_response(kind: apb::ActivityType, target: String, to: String, auth: Auth) {
|
||||||
let payload = apb::new()
|
let payload = apb::new()
|
||||||
.set_activity_type(Some(kind))
|
.set_activity_type(Some(kind))
|
||||||
|
|
|
@ -2,7 +2,7 @@ use leptos::*;
|
||||||
use leptos_router::*;
|
use leptos_router::*;
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
use leptos_use::{signal_debounced, signal_debounced_with_options, signal_throttled, signal_throttled_with_options, storage::use_local_storage, use_cookie, use_element_size, use_window_scroll, utils::{FromToStringCodec, JsonCodec}, DebounceOptions, ThrottleOptions, UseElementSizeReturn};
|
use leptos_use::{signal_throttled, storage::use_local_storage, use_cookie, use_element_size, use_window_scroll, utils::{FromToStringCodec, JsonCodec}, UseElementSizeReturn};
|
||||||
|
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
pub struct Feeds {
|
pub struct Feeds {
|
||||||
|
@ -184,7 +184,7 @@ fn Scrollable() -> impl IntoView {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
let element = create_node_ref();
|
let element = create_node_ref();
|
||||||
let should_load = use_scroll_limit(element, 500.0);
|
let should_load = use_scroll_limit(element, 1750.0);
|
||||||
provide_context(should_load);
|
provide_context(should_load);
|
||||||
view! {
|
view! {
|
||||||
<div class="mb-1" node_ref=element>
|
<div class="mb-1" node_ref=element>
|
||||||
|
@ -223,22 +223,15 @@ where
|
||||||
{
|
{
|
||||||
let (load, set_load) = create_signal(false);
|
let (load, set_load) = create_signal(false);
|
||||||
let (_x, y) = use_window_scroll();
|
let (_x, y) = use_window_scroll();
|
||||||
let UseElementSizeReturn { height: screen_height, .. } = use_element_size("html");
|
|
||||||
let UseElementSizeReturn { height, .. } = use_element_size(el);
|
let UseElementSizeReturn { height, .. } = use_element_size(el);
|
||||||
let scroll_state = Signal::derive(move || (y.get(), height.get(), screen_height.get()));
|
let scroll_state = Signal::derive(move || (y.get(), height.get()));
|
||||||
let scroll_state_throttled = signal_debounced(
|
let scroll_state_throttled = signal_throttled(scroll_state, 200.);
|
||||||
scroll_state,
|
|
||||||
50.
|
|
||||||
);
|
|
||||||
let _ = watch(
|
let _ = watch(
|
||||||
move || scroll_state_throttled.get(),
|
move || scroll_state_throttled.get(),
|
||||||
move |(y, height, screen), _, _| {
|
move |(y, height), _, _| {
|
||||||
let before = load.get();
|
let before = load.get();
|
||||||
let after = *height <= *screen || y + screen + offset >= *height;
|
let after = y + offset >= *height;
|
||||||
let force = *y + screen >= *height;
|
if after != before { set_load.set(after) };
|
||||||
if force || after != before || *height < *screen {
|
|
||||||
set_load.set(after)
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
|
|
@ -115,3 +115,16 @@ async fn send_follow_response(kind: apb::ActivityType, target: String, to: Strin
|
||||||
tracing::error!("failed posting follow response: {e}");
|
tracing::error!("failed posting follow response: {e}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn send_follow_request(target: String) {
|
||||||
|
let auth = use_context::<Auth>().expect("missing auth context");
|
||||||
|
spawn_local(async move {
|
||||||
|
let payload = serde_json::Value::Object(serde_json::Map::default())
|
||||||
|
.set_activity_type(Some(apb::ActivityType::Follow))
|
||||||
|
.set_object(apb::Node::link(target.clone()))
|
||||||
|
.set_to(apb::Node::links(vec![target]));
|
||||||
|
if let Err(e) = Http::post(&auth.outbox(), &payload, auth).await {
|
||||||
|
tracing::error!("failed sending follow request: {e}");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
use leptos::*;
|
use leptos::*;
|
||||||
|
use crate::prelude::*;
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
pub fn AboutPage() -> impl IntoView {
|
pub fn AboutPage() -> impl IntoView {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use apb::{ActivityMut, Object, ObjectMut};
|
use apb::{ActivityMut, ActorMut, Object, ObjectMut};
|
||||||
use leptos::*;
|
use leptos::*;
|
||||||
use crate::{prelude::*, DEFAULT_COLOR};
|
use crate::{prelude::*, DEFAULT_COLOR};
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,14 @@ pub fn Feed(tl: Timeline) -> impl IntoView {
|
||||||
if let Some(auto_scroll) = use_context::<Signal<bool>>() {
|
if let Some(auto_scroll) = use_context::<Signal<bool>>() {
|
||||||
let _ = leptos::watch(
|
let _ = leptos::watch(
|
||||||
move || auto_scroll.get(),
|
move || auto_scroll.get(),
|
||||||
move |at_end, _, _| if *at_end { tl.spawn_more(auth) },
|
move |new, old, _| {
|
||||||
|
match old {
|
||||||
|
None => tl.spawn_more(auth), // always do it first time
|
||||||
|
Some(old) => if *new && new != old {
|
||||||
|
tl.spawn_more(auth);
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue