From a39461e09a0503b802e62234817f114c8d3fd846 Mon Sep 17 00:00:00 2001 From: Fredrik Burmester Date: Thu, 2 Oct 2025 19:49:20 +0200 Subject: [PATCH] fix: handle optional chaining for 'other' media items in DownloadProvider --- providers/DownloadProvider.tsx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/providers/DownloadProvider.tsx b/providers/DownloadProvider.tsx index 8942a596..02ee1688 100644 --- a/providers/DownloadProvider.tsx +++ b/providers/DownloadProvider.tsx @@ -409,7 +409,7 @@ function useDownloadProvider() { console.log(`[DB] No item found with ID: ${id}`); // Check other media types - if (db.other[id]) { + if (db.other?.[id]) { return db.other[id]; } @@ -464,7 +464,7 @@ function useDownloadProvider() { Object.values(season.episodes), ), ); - const otherItems = Object.values(db.other); + const otherItems = Object.values(db.other || {}); const allItems = [...movies, ...episodes, ...otherItems]; return allItems; }, []); @@ -769,6 +769,7 @@ function useDownloadProvider() { ] = downloadedItem; } else if (item.Id) { // Handle other media types + if (!db.other) db.other = {}; db.other[item.Id] = downloadedItem; } @@ -981,9 +982,11 @@ function useDownloadProvider() { } } else { // Handle other media types - downloadedItem = db.other[id]; - if (downloadedItem) { - delete db.other[id]; + if (db.other) { + downloadedItem = db.other[id]; + if (downloadedItem) { + delete db.other[id]; + } } } @@ -1133,7 +1136,7 @@ function useDownloadProvider() { const db = getDownloadsDatabase(); if (db.movies[itemId]) { db.movies[itemId] = updatedItem; - } else if (db.other[itemId]) { + } else if (db.other?.[itemId]) { db.other[itemId] = updatedItem; } else { for (const series of Object.values(db.series)) {