fix: refresh libraries on drawer open and stop playlist page render loop
Continuous Integration / build_web (push) Failing after 0s
Continuous Integration / build (macos-latest) (push) Skipped
Continuous Integration / build (ubuntu-22.04) (push) Skipped
Continuous Integration / build (windows-11-arm) (push) Skipped
Continuous Integration / build (windows-latest) (push) Skipped
Continuous Integration / nightly_release (push) Skipped

- Zustand selector returned a new array on every render in PlaylistTitlePage,
  causing getSnapshot/useSyncExternalStore infinite updates.
- Cache playlist tracks per playlist id.
- Refetch server views each time the drawer opens so newly added libraries
  (e.g. Music) appear without restarting the app.
This commit is contained in:
1xDed committed 2026-11-27 11:57:49 +03:00
1 parent b00f93d262
commit cc1391bb7d
2 files changed
+13 -6

No files matched your search

+9 -2
View File
@@ -1,7 +1,7 @@
import { getUserViewApi } from "@jellyfin/sdk/lib/utils/api/user-view-api";
import { Divider, Drawer, List, ListItem, ListItemButton } from "@mui/material";
import { useQuery } from "@tanstack/react-query";
import React, { useMemo } from "react";
import React, { useEffect, useMemo } from "react";
import { useApiInContext } from "@/utils/store/api";
import { useCentralStore } from "@/utils/store/central";
import ListItemLink from "../listItemLink";
@@ -14,7 +14,7 @@ interface NavigationDrawerProps {
export const NavigationDrawer = ({ open, onClose }: NavigationDrawerProps) => {
const api = useApiInContext((s) => s.api);
const [user] = useCentralStore((s) => [s.currentUser]);
const user = useCentralStore((s) => s.currentUser);
const libraries = useQuery({
queryKey: ["libraries"],
@@ -31,6 +31,13 @@ export const NavigationDrawer = ({ open, onClose }: NavigationDrawerProps) => {
networkMode: "always",
});
// Libraries can be added on the server while the app is running; refresh
// the view list every time the drawer opens so they show up without restart.
const refetchLibraries = libraries.refetch;
useEffect(() => {
if (open) refetchLibraries();
}, [open, refetchLibraries]);
const drawerPaperProps = useMemo(() => {
return {
className: "glass library-drawer",