From 497ed64a09390155bc812d161c900287d04f664e Mon Sep 17 00:00:00 2001 From: Pas <74743263+Pasithea0@users.noreply.github.com> Date: Sat, 17 May 2025 21:41:31 -0600 Subject: [PATCH] hide if backend is out of date --- src/assets/locales/en.json | 7 +- .../player/atoms/settings/WatchPartyView.tsx | 340 ++++++++++-------- 2 files changed, 191 insertions(+), 156 deletions(-) diff --git a/src/assets/locales/en.json b/src/assets/locales/en.json index a3becdcc..7cea4bf7 100644 --- a/src/assets/locales/en.json +++ b/src/assets/locales/en.json @@ -940,8 +940,8 @@ }, "alone": "Alone", "withCount": "With {{count}} others", - "isHost": "You are hosting a watch party", - "isGuest": "You are a guest in a watch party", + "isHost": "Hosting on <0>{{backendName}}0>", + "isGuest": "Watching as a guest on <0>{{backendName}}0>", "hosting": "Hosting", "watching": "Watching", "syncing": "Syncing...", @@ -958,6 +958,7 @@ "join": "Join", "cancel": "Cancel", "contentMismatch": "Cannot join watch party: The content does not match the host's content.", - "episodeMismatch": "Cannot join watch party: You are watching a different episode than the host." + "episodeMismatch": "Cannot join watch party: You are watching a different episode than the host.", + "validating": "Validating watch party..." } } diff --git a/src/components/player/atoms/settings/WatchPartyView.tsx b/src/components/player/atoms/settings/WatchPartyView.tsx index d4c67f99..891dfb24 100644 --- a/src/components/player/atoms/settings/WatchPartyView.tsx +++ b/src/components/player/atoms/settings/WatchPartyView.tsx @@ -1,11 +1,14 @@ /* eslint-disable no-alert */ import { useEffect, useState } from "react"; -import { useTranslation } from "react-i18next"; +import { Trans, useTranslation } from "react-i18next"; +import { useAsync } from "react-use"; +import { getBackendMeta } from "@/backend/accounts/meta"; import { Button } from "@/components/buttons/Button"; import { Icon, Icons } from "@/components/Icon"; import { Spinner } from "@/components/layout/Spinner"; import { Menu } from "@/components/player/internals/ContextMenu"; +import { useBackendUrl } from "@/hooks/auth/useBackendUrl"; import { useOverlayRouter } from "@/hooks/useOverlayRouter"; import { useWatchPartySync } from "@/hooks/useWatchPartySync"; import { useWatchPartyStore } from "@/stores/watchParty"; @@ -19,6 +22,17 @@ export function WatchPartyView({ id }: { id: string }) { const [joinCode, setJoinCode] = useState(""); const [showJoinInput, setShowJoinInput] = useState(false); const [isJoining, setIsJoining] = useState(false); + const [backendName, setBackendName] = useState(""); + const backendUrl = useBackendUrl(); + + const backendMeta = useAsync(async () => { + if (!backendUrl) return; + return getBackendMeta(backendUrl); + }, [backendUrl]); + + const backendSupportsWatchParty = backendMeta?.value?.version + ? backendMeta.value.version >= "2.0.1" + : false; // Watch party store access const { @@ -35,6 +49,19 @@ export function WatchPartyView({ id }: { id: string }) { // Watch party sync data const { roomUsers } = useWatchPartySync(); + // Fetch backend name + useEffect(() => { + if (backendUrl && enabled) { + getBackendMeta(backendUrl) + .then((meta) => { + setBackendName(meta.name); + }) + .catch(() => { + setBackendName("Unknown Server"); + }); + } + }, [backendUrl, enabled]); + // Listen for validation status events useEffect(() => { const handleValidation = () => { @@ -113,173 +140,180 @@ export function WatchPartyView({ id }: { id: string }) { {t("player.menus.watchparty.notice")} - {enabled ? ( -
- {t("watchParty.validating")} -
-- {isHost - ? t("watchParty.shareCode") - : t("watchParty.connectedAsGuest")} + {backendSupportsWatchParty && + (enabled ? ( +
+ {t("watchParty.validating")}