mirror of
https://github.com/hzrd149/nostrudel.git
synced 2025-09-28 20:43:33 +02:00
show ended streams in select
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import { ReactNode, useMemo, useState } from "react";
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
ButtonGroup,
|
ButtonGroup,
|
||||||
@@ -14,12 +15,10 @@ import dayjs from "dayjs";
|
|||||||
|
|
||||||
import useParsedStreams from "../../hooks/use-parsed-streams";
|
import useParsedStreams from "../../hooks/use-parsed-streams";
|
||||||
import useSubject from "../../hooks/use-subject";
|
import useSubject from "../../hooks/use-subject";
|
||||||
import { ParsedStream, STREAM_KIND, getATag, parseStreamEvent } from "../../helpers/nostr/stream";
|
import { ParsedStream, STREAM_KIND, getATag } from "../../helpers/nostr/stream";
|
||||||
import useTimelineLoader from "../../hooks/use-timeline-loader";
|
import useTimelineLoader from "../../hooks/use-timeline-loader";
|
||||||
import RequireCurrentAccount from "../../providers/require-current-account";
|
import RequireCurrentAccount from "../../providers/require-current-account";
|
||||||
import { useCurrentAccount } from "../../hooks/use-current-account";
|
import { useCurrentAccount } from "../../hooks/use-current-account";
|
||||||
import { ReactNode, useCallback, useMemo, useState } from "react";
|
|
||||||
import { NostrEvent } from "../../types/nostr-event";
|
|
||||||
import { getEventUID } from "../../helpers/nostr/events";
|
import { getEventUID } from "../../helpers/nostr/events";
|
||||||
import { useReadRelayUrls } from "../../hooks/use-client-relays";
|
import { useReadRelayUrls } from "../../hooks/use-client-relays";
|
||||||
import useStreamChatTimeline from "../streams/stream/stream-chat/use-stream-chat-timeline";
|
import useStreamChatTimeline from "../streams/stream/stream-chat/use-stream-chat-timeline";
|
||||||
@@ -111,25 +110,13 @@ function StreamModerationPage() {
|
|||||||
const account = useCurrentAccount()!;
|
const account = useCurrentAccount()!;
|
||||||
const readRelays = useReadRelayUrls();
|
const readRelays = useReadRelayUrls();
|
||||||
|
|
||||||
const eventFilter = useCallback((event: NostrEvent) => {
|
const timeline = useTimelineLoader(account.pubkey + "-streams", readRelays, [
|
||||||
try {
|
|
||||||
const parsed = parseStreamEvent(event);
|
|
||||||
return parsed.status === "live";
|
|
||||||
} catch (e) {}
|
|
||||||
return false;
|
|
||||||
}, []);
|
|
||||||
const timeline = useTimelineLoader(
|
|
||||||
account.pubkey + "-streams",
|
|
||||||
readRelays,
|
|
||||||
[
|
|
||||||
{
|
{
|
||||||
authors: [account.pubkey],
|
authors: [account.pubkey],
|
||||||
kinds: [STREAM_KIND],
|
kinds: [STREAM_KIND],
|
||||||
},
|
},
|
||||||
{ "#p": [account.pubkey], kinds: [STREAM_KIND] },
|
{ "#p": [account.pubkey], kinds: [STREAM_KIND] },
|
||||||
],
|
]);
|
||||||
{ eventFilter },
|
|
||||||
);
|
|
||||||
|
|
||||||
const streamEvents = useSubject(timeline.timeline);
|
const streamEvents = useSubject(timeline.timeline);
|
||||||
const streams = useParsedStreams(streamEvents);
|
const streams = useParsedStreams(streamEvents);
|
||||||
@@ -146,7 +133,7 @@ function StreamModerationPage() {
|
|||||||
>
|
>
|
||||||
{streams.map((stream) => (
|
{streams.map((stream) => (
|
||||||
<option key={getEventUID(stream.event)} value={getATag(stream)}>
|
<option key={getEventUID(stream.event)} value={getATag(stream)}>
|
||||||
{stream.title}
|
{stream.title} ({stream.status})
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
</Select>
|
</Select>
|
||||||
|
Reference in New Issue
Block a user