refactor: useCallback

This commit is contained in:
2023-08-01 08:10:58 +02:00
parent 58c55f17b6
commit 1baecf41f2

View File

@ -1,4 +1,5 @@
import "./root.css"; import "./root.css";
import { useCallback } from "react";
import type { NostrEvent } from "@snort/system"; import type { NostrEvent } from "@snort/system";
import { VideoTile } from "element/video-tile"; import { VideoTile } from "element/video-tile";
@ -11,9 +12,12 @@ export function RootPage() {
const { live, planned, ended } = useStreamsFeed(); const { live, planned, ended } = useStreamsFeed();
const mutedHosts = new Set(getTagValues(login?.muted.tags ?? [], "p")); const mutedHosts = new Set(getTagValues(login?.muted.tags ?? [], "p"));
const followsHost = (ev: NostrEvent) => { const followsHost = useCallback(
return login?.follows.tags?.find((t) => t.at(1) === getHost(ev)); (ev: NostrEvent) => {
}; return login?.follows.tags.find((t) => t.at(1) === getHost(ev));
},
[login?.follows],
);
const hashtags = getTagValues(login?.follows.tags ?? [], "t"); const hashtags = getTagValues(login?.follows.tags ?? [], "t");
const following = live.filter(followsHost); const following = live.filter(followsHost);
const liveNow = live.filter((e) => !following.includes(e)); const liveNow = live.filter((e) => !following.includes(e));