feat: pubkey stream loading

chore: faster stream navigation
This commit is contained in:
2023-08-01 16:54:06 +01:00
parent 74c1a383b6
commit 90a7d2ca7e
7 changed files with 72 additions and 18 deletions

View File

@ -1,16 +1,22 @@
import { unwrap } from "@snort/shared";
import {
NostrEvent,
NostrLink,
NostrPrefix,
NoteCollection,
RequestBuilder,
TaggedRawEvent,
} from "@snort/system";
import { useRequestBuilder } from "@snort/system-react";
import { LIVE_STREAM } from "const";
import { System } from "index";
import { useMemo } from "react";
export function useCurrentStreamFeed(link: NostrLink, leaveOpen = false) {
export function useCurrentStreamFeed(
link: NostrLink,
leaveOpen = false,
evPreload?: NostrEvent
) {
const author =
link.type === NostrPrefix.Address ? unwrap(link.author) : link.id;
const sub = useMemo(() => {
@ -38,6 +44,10 @@ export function useCurrentStreamFeed(link: NostrLink, leaveOpen = false) {
const q = useRequestBuilder(System, NoteCollection, sub);
if (evPreload) {
q.add(evPreload as TaggedRawEvent);
}
return useMemo(() => {
const hosting = q.data?.filter(
(a) =>