mirror of
https://github.com/hzrd149/nostrudel.git
synced 2025-04-10 12:49:29 +02:00
show reused goals on stream view
This commit is contained in:
parent
57518fd78d
commit
eeda7ba3b1
@ -16,6 +16,7 @@ export type ParsedStream = {
|
||||
image?: string;
|
||||
updated: number;
|
||||
status: "live" | "ended" | string;
|
||||
goal?: string;
|
||||
starts?: number;
|
||||
ends?: number;
|
||||
identifier: string;
|
||||
@ -33,6 +34,7 @@ export function parseStreamEvent(stream: NostrEvent): ParsedStream {
|
||||
const endsTag = stream.tags.find((t) => t[0] === "ends")?.[1];
|
||||
const streaming = stream.tags.find((t) => t[0] === "streaming")?.[1];
|
||||
const recording = stream.tags.find((t) => t[0] === "recording")?.[1];
|
||||
const goal = stream.tags.find((t) => t[0] === "goal")?.[1];
|
||||
const identifier = stream.tags.find((t) => t[0] === "d")?.[1];
|
||||
|
||||
let relays = stream.tags.find((t) => t[0] === "relays");
|
||||
@ -74,6 +76,7 @@ export function parseStreamEvent(stream: NostrEvent): ParsedStream {
|
||||
status,
|
||||
starts: startTime,
|
||||
ends: endTime,
|
||||
goal,
|
||||
identifier,
|
||||
relays,
|
||||
};
|
||||
|
@ -11,18 +11,25 @@ import GoalProgress from "../../goals/components/goal-progress";
|
||||
import { getSharableEventAddress } from "../../../helpers/nip19";
|
||||
import GoalTopZappers from "../../goals/components/goal-top-zappers";
|
||||
import GoalZapButton from "../../goals/components/goal-zap-button";
|
||||
import singleEventService from "../../../services/single-event";
|
||||
|
||||
export default function StreamGoal({ stream, ...props }: Omit<CardProps, "children"> & { stream: ParsedStream }) {
|
||||
const [goal, setGoal] = useState<NostrEvent>();
|
||||
const relays = useReadRelayUrls(stream.relays);
|
||||
|
||||
useEffect(() => {
|
||||
const request = new NostrRequest(relays);
|
||||
request.onEvent.subscribe((event) => {
|
||||
setGoal(event);
|
||||
});
|
||||
request.start({ "#a": [getATag(stream)], kinds: [GOAL_KIND] });
|
||||
}, [stream.identifier, relays.join("|")]);
|
||||
if (stream.goal) {
|
||||
singleEventService.requestEvent(stream.goal, relays).then((event) => {
|
||||
setGoal(event);
|
||||
});
|
||||
} else {
|
||||
const request = new NostrRequest(relays);
|
||||
request.onEvent.subscribe((event) => {
|
||||
setGoal(event);
|
||||
});
|
||||
request.start({ "#a": [getATag(stream)], kinds: [GOAL_KIND] });
|
||||
}
|
||||
}, [stream.identifier, stream.goal, relays.join("|")]);
|
||||
|
||||
if (!goal) return null;
|
||||
const nevent = getSharableEventAddress(goal);
|
||||
|
Loading…
x
Reference in New Issue
Block a user