bugfix since for live chat feed

This commit is contained in:
2023-07-15 16:27:44 +01:00
parent 63873e2ac7
commit a1605e31d5
2 changed files with 7 additions and 4 deletions

View File

@ -32,7 +32,7 @@ export function Goal({
.reduce((acc, z) => acc + z.amount, 0);
}, [zaps]);
const progress = (soFar / goalAmount) * 100;
const progress = Math.max(0, Math.min(100, (soFar / goalAmount) * 100));
const isFinished = progress >= 100;
const previousValue = usePreviousValue(isFinished);

View File

@ -11,20 +11,23 @@ import { useMemo } from "react";
import { LIVE_STREAM_CHAT } from "const";
export function useLiveChatFeed(link: NostrLink, eZaps?: Array<string>) {
const since = useMemo(() =>
unixNow() - (60 * 60 * 24 * 7), // 7-days of zaps
[link.id]);
const sub = useMemo(() => {
const rb = new RequestBuilder(`live:${link.id}:${link.author}`);
rb.withOptions({
leaveOpen: true,
});
const zapsSince = unixNow() - (60 * 60 * 24 * 7); // 7-days of zaps
const aTag = `${link.kind}:${link.author}:${link.id}`;
rb.withFilter().kinds([LIVE_STREAM_CHAT]).tag("a", [aTag]).limit(100);
rb.withFilter().kinds([EventKind.ZapReceipt]).tag("a", [aTag]).since(zapsSince);
rb.withFilter().kinds([EventKind.ZapReceipt]).tag("a", [aTag]).since(since);
if (eZaps) {
rb.withFilter().kinds([EventKind.ZapReceipt]).tag("e", eZaps);
}
return rb;
}, [link, eZaps]);
}, [link.id, since, eZaps]);
const feed = useRequestBuilder<FlatNoteStore>(System, FlatNoteStore, sub);