fix: reduce reloads for timeline
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
kieran 2024-07-04 12:01:01 +01:00
parent 64ad548d75
commit dc4758d302
Signed by: Kieran
GPG Key ID: DE71CEB3925BE941
2 changed files with 15 additions and 9 deletions

View File

@ -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);

View File

@ -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 (
<>