Skip to content

Commit

Permalink
Fix: Fixed a Watchlist related crash
Browse files Browse the repository at this point in the history
  • Loading branch information
Ipmake authored Jan 14, 2025
1 parent 862fec1 commit 2370766
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
16 changes: 10 additions & 6 deletions frontend/src/plex/plextv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,15 @@ export namespace PlexTv {
}

export async function getWatchlist(): Promise<Plex.Metadata[]> {
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 [];
}
}
}
1 change: 1 addition & 0 deletions frontend/src/states/WatchListCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const useWatchListCache = create<WatchListCacheState>((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,
Expand Down

0 comments on commit 2370766

Please sign in to comment.