diff --git a/src/components/libraryHeader/index.tsx b/src/components/libraryHeader/index.tsx index c82e9c1..3252a16 100644 --- a/src/components/libraryHeader/index.tsx +++ b/src/components/libraryHeader/index.tsx @@ -25,6 +25,7 @@ import BackButton from "../buttons/backButton"; import CastButton from "../buttons/castButton"; import { FiltersDialogTrigger } from "../filtersDialog"; import { UserAvatarMenu } from "../userAvatarMenu"; +import WindowControls from "../windowControls"; import "./libraryHeader.scss"; const route = getRouteApi("/_api/library/$id"); @@ -395,6 +396,7 @@ export const LibraryHeader = () => {
favorite
+ diff --git a/src/components/playback/audioPlayer/index.tsx b/src/components/playback/audioPlayer/index.tsx index 5f15f54..e8f37cc 100644 --- a/src/components/playback/audioPlayer/index.tsx +++ b/src/components/playback/audioPlayer/index.tsx @@ -84,6 +84,7 @@ const AudioPlayer = () => { const [playing, setPlaying] = useState(false); const [progress, setProgress] = useState(0); const [selectedRemoteId, setSelectedRemoteId] = useState(null); + const remoteActiveRef = useRef(false); const [moreAnchor, setMoreAnchor] = useState(null); const [remoteVolumeDraft, setRemoteVolumeDraft] = useState( null, @@ -98,9 +99,12 @@ const AudioPlayer = () => { return result.data; }, enabled: !!api && !!user?.Id, - // Do not keep polling the server while the window is hidden. - refetchInterval: () => - document.visibilityState === "visible" ? 3000 : false, + // Poll quickly only while something is actually playing; idle devices + // are checked less often, and never while the window is hidden. + refetchInterval: () => { + if (document.visibilityState !== "visible") return false; + return display || remoteActiveRef.current ? 3000 : 8000; + }, refetchIntervalInBackground: false, staleTime: 1500, networkMode: "always", @@ -126,6 +130,7 @@ const AudioPlayer = () => { : !display ? playingRemote : undefined; + remoteActiveRef.current = Boolean(remote); const activeItem: BaseItemDto | undefined | null = remote?.NowPlayingItem ?? item; diff --git a/src/components/windowControls/windowChrome.tsx b/src/components/windowControls/windowChrome.tsx index 91e61eb..de4e726 100644 --- a/src/components/windowControls/windowChrome.tsx +++ b/src/components/windowControls/windowChrome.tsx @@ -31,8 +31,14 @@ const WindowChrome = () => { const { pathname } = useLocation(); if (isMac) return null; if (pathname === "/home" || shouldShowAppBar(pathname)) return null; - // The video player has its own fullscreen UI. - if (pathname.startsWith("/player")) return null; + // These routes draw their own headers and include WindowControls. + if ( + pathname.startsWith("/library") || + pathname.startsWith("/search") || + pathname.startsWith("/player") + ) { + return null; + } return ; }; diff --git a/src/routes/_api/search/index.tsx b/src/routes/_api/search/index.tsx index 03806dd..90f186d 100644 --- a/src/routes/_api/search/index.tsx +++ b/src/routes/_api/search/index.tsx @@ -26,8 +26,11 @@ import { } from "@mui/material"; import { createFileRoute, Outlet, useNavigate } from "@tanstack/react-router"; import { useShallow } from "zustand/shallow"; +import { NavigationDrawer } from "@/components/appBar/navigationDrawer"; import BackButton from "@/components/buttons/backButton"; import { UserAvatarMenu } from "@/components/userAvatarMenu"; +import WindowControls from "@/components/windowControls"; +import { useApiInContext } from "@/utils/store/api"; import useDebounce from "@/utils/hooks/useDebounce"; import { useCentralStore } from "@/utils/store/central"; import useSearchStore from "@/utils/store/search"; @@ -50,7 +53,7 @@ const CATEGORIES = [ ]; function SearchPage() { - const api = Route.useRouteContext().api; + const api = useApiInContext((state) => state.api); const navigate = useNavigate(); const { query } = Route.useSearch(); const [setBackdrop] = useBackdropStore(useShallow((s) => [s.setBackdrop])); @@ -184,22 +187,24 @@ function SearchAppBar({ const toggleSearchDialog = useSearchStore( useShallow((s) => s.toggleSearchDialog), ); + const [showDrawer, setShowDrawer] = useState(false); return ( - -
- -
menu
-
+ <> + +
+ setShowDrawer(true)}> +
menu
+
favorite
+
-
+ + setShowDrawer(false)} + /> + ); } @@ -437,7 +448,14 @@ function CategorySection({ category, query, api, user, onResult }: any) { const limit = 20; const { data, isLoading } = useQuery({ - queryKey: ["search", "category", category.value, query], + queryKey: [ + "search", + "category", + category.value, + query, + user?.Id, + api?.basePath, + ], queryFn: async () => { if (!api || !user?.Id) return { items: [], total: 0 }; @@ -472,7 +490,7 @@ function CategorySection({ category, query, api, user, onResult }: any) { }); return { items: res.data.Items, total: res.data.TotalRecordCount }; }, - enabled: !!query, + enabled: Boolean(api && user?.Id && query), }); useEffect(() => {