Merge pull request 'fix: only show awards from stream start' (#77) from awards-times into main
Reviewed-on: Kieran/stream#77 Reviewed-by: Kieran <kieran@noreply.localhost>
This commit is contained in:
@ -8,6 +8,7 @@ import {
|
|||||||
parseZap,
|
parseZap,
|
||||||
encodeTLV,
|
encodeTLV,
|
||||||
} from "@snort/system";
|
} from "@snort/system";
|
||||||
|
import { unixNow } from "@snort/shared";
|
||||||
import { useEffect, useMemo } from "react";
|
import { useEffect, useMemo } from "react";
|
||||||
import uniqBy from "lodash.uniqby";
|
import uniqBy from "lodash.uniqby";
|
||||||
|
|
||||||
@ -28,7 +29,7 @@ import { useLogin } from "hooks/login";
|
|||||||
import useTopZappers from "hooks/top-zappers";
|
import useTopZappers from "hooks/top-zappers";
|
||||||
import { useAddress } from "hooks/event";
|
import { useAddress } from "hooks/event";
|
||||||
import { formatSats } from "number";
|
import { formatSats } from "number";
|
||||||
import { LIVE_STREAM_CHAT } from "const";
|
import { WEEK, LIVE_STREAM_CHAT } from "const";
|
||||||
import { findTag, getTagValues, getHost } from "utils";
|
import { findTag, getTagValues, getHost } from "utils";
|
||||||
import { System } from "index";
|
import { System } from "index";
|
||||||
|
|
||||||
@ -91,7 +92,6 @@ export function LiveChat({
|
|||||||
height?: number;
|
height?: number;
|
||||||
}) {
|
}) {
|
||||||
const host = getHost(ev);
|
const host = getHost(ev);
|
||||||
const { badges, awards } = useBadges(host);
|
|
||||||
const feed = useLiveChatFeed(link, goal ? [goal.id] : undefined);
|
const feed = useLiveChatFeed(link, goal ? [goal.id] : undefined);
|
||||||
const login = useLogin();
|
const login = useLogin();
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -101,6 +101,11 @@ export function LiveChat({
|
|||||||
System.ProfileLoader.TrackMetadata(pubkeys);
|
System.ProfileLoader.TrackMetadata(pubkeys);
|
||||||
return () => System.ProfileLoader.UntrackMetadata(pubkeys);
|
return () => System.ProfileLoader.UntrackMetadata(pubkeys);
|
||||||
}, [feed.zaps]);
|
}, [feed.zaps]);
|
||||||
|
const started = useMemo(() => {
|
||||||
|
const starts = findTag(ev, "starts");
|
||||||
|
return starts ? Number(starts) : unixNow() - WEEK;
|
||||||
|
}, [ev]);
|
||||||
|
const { badges, awards } = useBadges(host, started);
|
||||||
const mutedPubkeys = useMemo(() => {
|
const mutedPubkeys = useMemo(() => {
|
||||||
return new Set(getTagValues(login?.muted.tags ?? [], "p"));
|
return new Set(getTagValues(login?.muted.tags ?? [], "p"));
|
||||||
}, [login]);
|
}, [login]);
|
||||||
|
@ -7,18 +7,16 @@ import {
|
|||||||
RequestBuilder,
|
RequestBuilder,
|
||||||
} from "@snort/system";
|
} from "@snort/system";
|
||||||
import { useRequestBuilder } from "@snort/system-react";
|
import { useRequestBuilder } from "@snort/system-react";
|
||||||
import { unixNow } from "@snort/shared";
|
|
||||||
|
|
||||||
import { findTag, toAddress, getTagValues } from "utils";
|
import { findTag, toAddress, getTagValues } from "utils";
|
||||||
import { WEEK } from "const";
|
|
||||||
import { System } from "index";
|
import { System } from "index";
|
||||||
import type { Badge } from "types";
|
import type { Badge } from "types";
|
||||||
|
|
||||||
export function useBadges(
|
export function useBadges(
|
||||||
pubkey: string,
|
pubkey: string,
|
||||||
|
since: number,
|
||||||
leaveOpen = true
|
leaveOpen = true
|
||||||
): { badges: Badge[]; awards: TaggedRawEvent[] } {
|
): { badges: Badge[]; awards: TaggedRawEvent[] } {
|
||||||
const since = useMemo(() => unixNow() - WEEK, [pubkey]);
|
|
||||||
const rb = useMemo(() => {
|
const rb = useMemo(() => {
|
||||||
const rb = new RequestBuilder(`badges:${pubkey.slice(0, 12)}`);
|
const rb = new RequestBuilder(`badges:${pubkey.slice(0, 12)}`);
|
||||||
rb.withOptions({ leaveOpen });
|
rb.withOptions({ leaveOpen });
|
||||||
|
Reference in New Issue
Block a user