bugfix since for live chat feed
This commit is contained in:
@ -32,7 +32,7 @@ export function Goal({
|
|||||||
.reduce((acc, z) => acc + z.amount, 0);
|
.reduce((acc, z) => acc + z.amount, 0);
|
||||||
}, [zaps]);
|
}, [zaps]);
|
||||||
|
|
||||||
const progress = (soFar / goalAmount) * 100;
|
const progress = Math.max(0, Math.min(100, (soFar / goalAmount) * 100));
|
||||||
const isFinished = progress >= 100;
|
const isFinished = progress >= 100;
|
||||||
const previousValue = usePreviousValue(isFinished);
|
const previousValue = usePreviousValue(isFinished);
|
||||||
|
|
||||||
|
@ -11,20 +11,23 @@ import { useMemo } from "react";
|
|||||||
import { LIVE_STREAM_CHAT } from "const";
|
import { LIVE_STREAM_CHAT } from "const";
|
||||||
|
|
||||||
export function useLiveChatFeed(link: NostrLink, eZaps?: Array<string>) {
|
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 sub = useMemo(() => {
|
||||||
const rb = new RequestBuilder(`live:${link.id}:${link.author}`);
|
const rb = new RequestBuilder(`live:${link.id}:${link.author}`);
|
||||||
rb.withOptions({
|
rb.withOptions({
|
||||||
leaveOpen: true,
|
leaveOpen: true,
|
||||||
});
|
});
|
||||||
const zapsSince = unixNow() - (60 * 60 * 24 * 7); // 7-days of zaps
|
|
||||||
const aTag = `${link.kind}:${link.author}:${link.id}`;
|
const aTag = `${link.kind}:${link.author}:${link.id}`;
|
||||||
rb.withFilter().kinds([LIVE_STREAM_CHAT]).tag("a", [aTag]).limit(100);
|
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) {
|
if (eZaps) {
|
||||||
rb.withFilter().kinds([EventKind.ZapReceipt]).tag("e", eZaps);
|
rb.withFilter().kinds([EventKind.ZapReceipt]).tag("e", eZaps);
|
||||||
}
|
}
|
||||||
return rb;
|
return rb;
|
||||||
}, [link, eZaps]);
|
}, [link.id, since, eZaps]);
|
||||||
|
|
||||||
const feed = useRequestBuilder<FlatNoteStore>(System, FlatNoteStore, sub);
|
const feed = useRequestBuilder<FlatNoteStore>(System, FlatNoteStore, sub);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user