- Game categories
- Move stream setup/config to dashboard
- Reorg files / cleanup
- NSFW improvements
This commit is contained in:
2024-03-06 16:31:44 +00:00
parent 0a9bd35f43
commit a385ca3271
49 changed files with 824 additions and 513 deletions

View File

@ -1,11 +1,11 @@
import { unwrap } from "@snort/shared";
import { NostrEvent, NostrLink, NostrPrefix, RequestBuilder } from "@snort/system";
import { NostrLink, NostrPrefix, RequestBuilder, TaggedNostrEvent } from "@snort/system";
import { useRequestBuilder } from "@snort/system-react";
import { useMemo } from "react";
import { LIVE_STREAM } from "@/const";
export function useCurrentStreamFeed(link: NostrLink, leaveOpen = false, evPreload?: NostrEvent) {
export function useCurrentStreamFeed(link: NostrLink, leaveOpen = false, evPreload?: TaggedNostrEvent) {
const author = link.type === NostrPrefix.Address ? unwrap(link.author) : link.id;
const sub = useMemo(() => {
const b = new RequestBuilder(`current-event:${link.id}`);

28
src/hooks/game-info.ts Normal file
View File

@ -0,0 +1,28 @@
import { AllCategories } from "@/pages/category";
import GameDatabase, { GameInfo } from "@/service/game-database";
import { useEffect, useState } from "react";
export default function useGameInfo(gameId?: string, gameInfo?: GameInfo) {
const [game, setGame] = useState<GameInfo | undefined>(gameInfo);
useEffect(() => {
if (!gameInfo && gameId) {
const [prefix, id] = gameId.split(":");
if (prefix === "internal" || !gameId.includes(":")) {
const ix = AllCategories.find(a => a.id === id || a.id === gameId);
if (ix) {
setGame({
id: `internal:${ix.id}`,
name: ix.name,
genres: ix.tags,
className: ix.className
});
}
} else {
new GameDatabase().getGame(gameId).then(setGame);
}
}
}, [gameInfo, gameId]);
return game;
}

View File

@ -0,0 +1,25 @@
import { NostrStreamProvider, StreamProviderStore } from "@/providers";
import { ManualProvider } from "@/providers/manual";
import { findTag } from "@/utils";
import { NostrEvent } from "@snort/system";
import { useSyncExternalStore } from "react";
export function useStreamProvider() {
return useSyncExternalStore(
c => StreamProviderStore.hook(c),
() => StreamProviderStore.snapshot()
);
}
export function getCurrentStreamProvider(ev?: NostrEvent) {
const providers = StreamProviderStore.snapshot();
if (ev) {
const service = findTag(ev, "service");
if (service) {
return new NostrStreamProvider("", service);
} else {
return new ManualProvider();
}
}
return providers.at(0);
}

View File

@ -1,9 +0,0 @@
import { StreamProviderStore } from "@/providers";
import { useSyncExternalStore } from "react";
export function useStreamProvider() {
return useSyncExternalStore(
c => StreamProviderStore.hook(c),
() => StreamProviderStore.snapshot()
);
}