Home: ignore paging for trending panel

This commit is contained in:
thislight 2024-08-22 15:31:15 +08:00
parent 964298f407
commit 8dc261a863
No known key found for this signature in database
GPG key ID: A50F9451AC56A63E
2 changed files with 61 additions and 20 deletions

View file

@ -9,6 +9,8 @@ import {
type ParentComponent,
children,
Suspense,
Match,
Switch as JsSwitch
} from "solid-js";
import { useDocumentTitle } from "../utils";
import { type mastodon } from "masto";
@ -49,6 +51,7 @@ const TimelinePanel: Component<{
client: mastodon.rest.Client;
name: "home" | "public" | "trends";
prefetch?: boolean;
fullRefetch?: number;
openFullScreenToot: (
toot: mastodon.v1.Status,
@ -60,10 +63,12 @@ const TimelinePanel: Component<{
timeline,
snapshot,
{ refetch: refetchTimeline, mutate: mutateTimeline },
] = useTimeline(() =>
props.name !== "trends"
? props.client.v1.timelines[props.name]
: props.client.v1.trends.statuses,
] = useTimeline(
() =>
props.name !== "trends"
? props.client.v1.timelines[props.name]
: props.client.v1.trends.statuses,
{ fullRefresh: props.fullRefetch },
);
const [expandedThreadId, setExpandedThreadId] = createSignal<string>();
@ -176,15 +181,26 @@ const TimelinePanel: Component<{
"justify-content": "center",
}}
>
<Button
variant="contained"
onClick={[refetchTimeline, "old"]}
disabled={snapshot.loading}
>
<Show when={snapshot.error} fallback={<>Load More</>}>
Retry
</Show>
</Button>
<JsSwitch>
<Match when={snapshot.error}>
<Button
variant="contained"
onClick={[refetchTimeline, "old"]}
disabled={snapshot.loading}
>
Retry
</Button>
</Match>
<Match when={typeof props.fullRefetch === "undefined"}>
<Button
variant="contained"
onClick={[refetchTimeline, "old"]}
disabled={snapshot.loading}
>
Load More
</Button>
</Match>
</JsSwitch>
</div>
</>
);
@ -403,6 +419,7 @@ const Home: ParentComponent = (props) => {
name="trends"
prefetch={prefetching()}
openFullScreenToot={openFullScreenToot}
fullRefetch={120}
/>
</div>
</div>