From 23707662c1651cdc2013e254b0971b1c1bbaa48f Mon Sep 17 00:00:00 2001 From: Ipmake Date: Tue, 14 Jan 2025 12:28:56 +0100 Subject: [PATCH] Fix: Fixed a Watchlist related crash --- frontend/src/plex/plextv.ts | 16 ++++++++++------ frontend/src/states/WatchListCache.ts | 1 + 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/frontend/src/plex/plextv.ts b/frontend/src/plex/plextv.ts index 4e518ba..a6442bb 100644 --- a/frontend/src/plex/plextv.ts +++ b/frontend/src/plex/plextv.ts @@ -35,11 +35,15 @@ export namespace PlexTv { } export async function getWatchlist(): Promise { - const res = await axios.get(`https://discover.provider.plex.tv/library/sections/watchlist/all?${queryBuilder({ - "X-Plex-Token": localStorage.getItem("accAccessToken") as string, - "includeAdvanced": 1, - "includeMeta": 1, - })}`) - return res.data.MediaContainer.Metadata; + try { + const res = await axios.get(`https://discover.provider.plex.tv/library/sections/watchlist/all?${queryBuilder({ + "X-Plex-Token": localStorage.getItem("accAccessToken") as string, + "includeAdvanced": 1, + "includeMeta": 1, + })}`) + return res.data.MediaContainer.Metadata; + } catch (error) { + return []; + } } } \ No newline at end of file diff --git a/frontend/src/states/WatchListCache.ts b/frontend/src/states/WatchListCache.ts index a22834b..1e1ed19 100644 --- a/frontend/src/states/WatchListCache.ts +++ b/frontend/src/states/WatchListCache.ts @@ -25,6 +25,7 @@ export const useWatchListCache = create((set) => ({ }, loadWatchListCache: async () => { const watchList = await PlexTv.getWatchlist(); + if(!watchList) return; set({ watchListCache: watchList }); }, isOnWatchList: (item): boolean => useWatchListCache.getState().watchListCache.find((i) => i.guid === item) !== undefined,