Track zapper profiles
This commit is contained in:
@ -6,6 +6,7 @@ import {
|
|||||||
parseZap,
|
parseZap,
|
||||||
} from "@snort/system";
|
} from "@snort/system";
|
||||||
import {
|
import {
|
||||||
|
useEffect,
|
||||||
useMemo,
|
useMemo,
|
||||||
} from "react";
|
} from "react";
|
||||||
|
|
||||||
@ -21,7 +22,7 @@ import { LIVE_STREAM_CHAT } from "../const";
|
|||||||
import useEventFeed from "../hooks/event-feed";
|
import useEventFeed from "../hooks/event-feed";
|
||||||
import { ChatMessage } from "./chat-message";
|
import { ChatMessage } from "./chat-message";
|
||||||
import { WriteMessage } from "./write-message";
|
import { WriteMessage } from "./write-message";
|
||||||
import { getHost } from "utils";
|
import { findTag, getHost } from "utils";
|
||||||
|
|
||||||
export interface LiveChatOptions {
|
export interface LiveChatOptions {
|
||||||
canWrite?: boolean;
|
canWrite?: boolean;
|
||||||
@ -56,6 +57,12 @@ function TopZappers({ zaps }: { zaps: ParsedZap[] }) {
|
|||||||
export function LiveChat({ link, options, height, }: { link: NostrLink, options?: LiveChatOptions, height?: number }) {
|
export function LiveChat({ link, options, height, }: { link: NostrLink, options?: LiveChatOptions, height?: number }) {
|
||||||
const feed = useLiveChatFeed(link);
|
const feed = useLiveChatFeed(link);
|
||||||
const login = useLogin();
|
const login = useLogin();
|
||||||
|
useEffect(() => {
|
||||||
|
const pubkeys = [...new Set(feed.zaps.flatMap(a => [a.pubkey, findTag(a, "p")!]))];
|
||||||
|
System.ProfileLoader.TrackMetadata(pubkeys);
|
||||||
|
return () => System.ProfileLoader.UntrackMetadata(pubkeys);
|
||||||
|
}, [feed.zaps]);
|
||||||
|
|
||||||
const zaps = feed.zaps
|
const zaps = feed.zaps
|
||||||
.map((ev) => parseZap(ev, System.ProfileLoader.Cache))
|
.map((ev) => parseZap(ev, System.ProfileLoader.Cache))
|
||||||
.filter((z) => z && z.valid);
|
.filter((z) => z && z.valid);
|
||||||
|
Reference in New Issue
Block a user