From 9f75945cf63eb4e1e7b0ff6966e92aa5398237aa Mon Sep 17 00:00:00 2001 From: Nyagami Date: Mon, 15 Jan 2024 20:47:36 +0700 Subject: [PATCH] fix: skip chapter when error downloading --- src/hooks/persisted/useDownload.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/hooks/persisted/useDownload.ts b/src/hooks/persisted/useDownload.ts index cd0b09c7..de18418a 100644 --- a/src/hooks/persisted/useDownload.ts +++ b/src/hooks/persisted/useDownload.ts @@ -47,10 +47,6 @@ const downloadChapterAction = async (taskData?: TaskData) => { chapter.id, chapter.url, ); - - // get the newtest queue; - queue = getMMKVObject(DOWNLOAD_QUEUE) || []; - setMMKVObject(DOWNLOAD_QUEUE, queue.slice(1)); } catch (error: any) { Notifications.scheduleNotificationAsync({ content: { @@ -59,6 +55,10 @@ const downloadChapterAction = async (taskData?: TaskData) => { }, trigger: null, }); + } finally { + // get the newtest queue; + queue = getMMKVObject(DOWNLOAD_QUEUE) || []; + setMMKVObject(DOWNLOAD_QUEUE, queue.slice(1)); } if (queue.length > 1 && taskData) { @@ -68,6 +68,7 @@ const downloadChapterAction = async (taskData?: TaskData) => { } } finally { MMKVStorage.delete(BACKGROUND_ACTION); + BackgroundService.stop(); } };