fix: reduce reloads for timeline
This commit is contained in:
parent
64ad548d75
commit
dc4758d302
@ -28,7 +28,7 @@ export default function TimelineChunk(props: TimelineChunkProps) {
|
||||
f.since(props.chunk.since).until(props.chunk.until);
|
||||
}
|
||||
return rb;
|
||||
}, [props.id, props.chunk, props.builder]);
|
||||
}, [props.id, props.chunk.until, props.builder]);
|
||||
|
||||
const feed = useRequestBuilder(sub);
|
||||
|
||||
|
@ -2,7 +2,7 @@ import "./Timeline.css";
|
||||
|
||||
import { unixNow } from "@snort/shared";
|
||||
import { EventKind, NostrEvent, RequestBuilder } from "@snort/system";
|
||||
import { ReactNode, useState } from "react";
|
||||
import { ReactNode, useCallback, useState } from "react";
|
||||
|
||||
import { DisplayAs, DisplayAsSelector } from "@/Components/Feed/DisplayAsSelector";
|
||||
import useFollowsControls from "@/Hooks/useFollowControls";
|
||||
@ -41,14 +41,20 @@ const TimelineFollows = (props: TimelineFollowsProps) => {
|
||||
firstChunkSize: Hour * 2,
|
||||
});
|
||||
|
||||
const builder = (rb: RequestBuilder) => {
|
||||
rb.withFilter().authors(followList).kinds([EventKind.TextNote, EventKind.Repost, EventKind.Polls]);
|
||||
};
|
||||
const builder = useCallback(
|
||||
(rb: RequestBuilder) => {
|
||||
rb.withFilter().authors(followList).kinds([EventKind.TextNote, EventKind.Repost, EventKind.Polls]);
|
||||
},
|
||||
[followList],
|
||||
);
|
||||
|
||||
const filterEvents = (a: NostrEvent) =>
|
||||
(props.noteFilter?.(a) ?? true) &&
|
||||
(props.postsOnly ? !a.tags.some(b => b[0] === "e" || b[0] === "a") : true) &&
|
||||
(isFollowing(a.pubkey) || a.tags.filter(a => a[0] === "t").length < 5);
|
||||
const filterEvents = useCallback(
|
||||
(a: NostrEvent) =>
|
||||
(props.noteFilter?.(a) ?? true) &&
|
||||
(props.postsOnly ? !a.tags.some(b => b[0] === "e" || b[0] === "a") : true) &&
|
||||
(isFollowing(a.pubkey) || a.tags.filter(a => a[0] === "t").length < 5),
|
||||
[props.noteFilter, props.postsOnly, followList],
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
|
Loading…
x
Reference in New Issue
Block a user