diff --git a/src/components/Settings/SettingsPlex.tsx b/src/components/Settings/SettingsPlex.tsx index b95fd7c2e..34ded09a8 100644 --- a/src/components/Settings/SettingsPlex.tsx +++ b/src/components/Settings/SettingsPlex.tsx @@ -48,7 +48,7 @@ interface SyncStatus { running: boolean; progress: number; total: number; - currentLibrary: Library; + currentLibrary?: Library; libraries: Library[]; } @@ -86,12 +86,17 @@ const SettingsPlex: React.FC = ({ onComplete }) => { const syncLibraries = async () => { setIsSyncing(true); + + const params: { sync: boolean; enable?: string } = { + sync: true, + }; + + if (activeLibraries.length > 0) { + params.enable = activeLibraries.join(','); + } + await axios.get('/api/v1/settings/plex/library', { - params: { - sync: true, - enable: - activeLibraries.length > 0 ? activeLibraries.join(',') : undefined, - }, + params, }); setIsSyncing(false); revalidate(); @@ -118,13 +123,16 @@ const SettingsPlex: React.FC = ({ onComplete }) => { const toggleLibrary = async (libraryId: string) => { setIsSyncing(true); if (activeLibraries.includes(libraryId)) { + const params: { enable?: string } = {}; + + if (activeLibraries.length > 1) { + params.enable = activeLibraries + .filter((id) => id !== libraryId) + .join(','); + } + await axios.get('/api/v1/settings/plex/library', { - params: { - enable: - activeLibraries.length > 0 - ? activeLibraries.filter((id) => id !== libraryId).join(',') - : undefined, - }, + params, }); } else { await axios.get('/api/v1/settings/plex/library', { @@ -369,25 +377,29 @@ const SettingsPlex: React.FC = ({ onComplete }) => {
{dataSync?.running && ( <> -
- - - -
+ {dataSync.currentLibrary && ( +
+ + + +
+ )}
- library.id === dataSync.currentLibrary.id - ) + 1 - ).length, + count: dataSync.currentLibrary + ? dataSync.libraries.slice( + dataSync.libraries.findIndex( + (library) => + library.id === dataSync.currentLibrary?.id + ) + 1 + ).length + : 0, }} />