fix: short links
This commit is contained in:
@ -4,9 +4,10 @@ import { unixNow } from "@snort/shared";
|
||||
import { useMemo } from "react";
|
||||
import { LIVE_STREAM_CHAT, WEEK } from "const";
|
||||
|
||||
export function useLiveChatFeed(link: NostrLink, eZaps?: Array<string>, limit = 100) {
|
||||
const since = useMemo(() => unixNow() - WEEK, [link.id]);
|
||||
export function useLiveChatFeed(link?: NostrLink, eZaps?: Array<string>, limit = 100) {
|
||||
const since = useMemo(() => unixNow() - WEEK, [link?.id]);
|
||||
const sub = useMemo(() => {
|
||||
if (!link) return null;
|
||||
const rb = new RequestBuilder(`live:${link.id}:${link.author}`);
|
||||
rb.withOptions({
|
||||
leaveOpen: true,
|
||||
@ -14,7 +15,7 @@ export function useLiveChatFeed(link: NostrLink, eZaps?: Array<string>, limit =
|
||||
const aTag = `${link.kind}:${link.author}:${link.id}`;
|
||||
rb.withFilter().kinds([LIVE_STREAM_CHAT]).tag("a", [aTag]).limit(limit);
|
||||
return rb;
|
||||
}, [link.id, since, eZaps]);
|
||||
}, [link?.id, since, eZaps]);
|
||||
|
||||
const feed = useRequestBuilder(NoteCollection, sub);
|
||||
|
||||
@ -23,8 +24,8 @@ export function useLiveChatFeed(link: NostrLink, eZaps?: Array<string>, limit =
|
||||
}, [feed.data]);
|
||||
|
||||
const reactions = useReactions(
|
||||
`live:${link.id}:${link.author}:reactions`,
|
||||
messages.map(a => NostrLink.fromEvent(a)).concat(link),
|
||||
`live:${link?.id}:${link?.author}:reactions`,
|
||||
messages.map(a => NostrLink.fromEvent(a)).concat(link ? [link] : []),
|
||||
undefined,
|
||||
true
|
||||
);
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { fetchNip05Pubkey, hexToBech32 } from "@snort/shared";
|
||||
import { fetchNip05Pubkey } from "@snort/shared";
|
||||
import { NostrLink, tryParseNostrLink, NostrPrefix } from "@snort/system";
|
||||
import { useState, useEffect } from "react";
|
||||
import { useParams } from "react-router-dom";
|
||||
@ -16,11 +16,7 @@ export function useStreamLink() {
|
||||
const [handle, domain] = (params.id.includes("@") ? params.id : `${params.id}@zap.stream`).split("@");
|
||||
fetchNip05Pubkey(handle, domain).then(d => {
|
||||
if (d) {
|
||||
setLink({
|
||||
id: d,
|
||||
type: NostrPrefix.PublicKey,
|
||||
encode: () => hexToBech32(NostrPrefix.PublicKey, d),
|
||||
} as NostrLink);
|
||||
setLink(new NostrLink(NostrPrefix.PublicKey, d));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -34,8 +34,9 @@ interface StatSlot {
|
||||
|
||||
export function StreamSummary({ link, preload }: { link: NostrLink; preload?: NostrEvent }) {
|
||||
const ev = useCurrentStreamFeed(link, true, preload);
|
||||
const data = useLiveChatFeed(link, undefined, 5_000);
|
||||
const reactions = useEventReactions(link, data.reactions);
|
||||
const thisLink = ev ? NostrLink.fromEvent(ev) : undefined;
|
||||
const data = useLiveChatFeed(thisLink, undefined, 5_000);
|
||||
const reactions = useEventReactions(thisLink ?? link, data.reactions);
|
||||
|
||||
const chatSummary = useMemo(() => {
|
||||
return Object.entries(
|
||||
|
Reference in New Issue
Block a user