From fbe5a3212bf999068e7ca7075bbdca910baff31d Mon Sep 17 00:00:00 2001 From: jeffvli Date: Sun, 3 Oct 2021 23:26:18 -0700 Subject: [PATCH] Add clear artist cache, add success toasts --- .../settings/ConfigPanels/CacheConfig.tsx | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/components/settings/ConfigPanels/CacheConfig.tsx b/src/components/settings/ConfigPanels/CacheConfig.tsx index a329e13..8f474c9 100644 --- a/src/components/settings/ConfigPanels/CacheConfig.tsx +++ b/src/components/settings/ConfigPanels/CacheConfig.tsx @@ -54,9 +54,10 @@ const CacheConfig = () => { } }); }); + notifyToast('success', `Cleared song cache`); }; - const handleClearImageCache = (type: 'playlist' | 'album') => { + const handleClearImageCache = (type: 'playlist' | 'album' | 'artist') => { const imageCachePath = getImageCachePath(); fs.readdir(imageCachePath, (err, files) => { if (err) { @@ -66,7 +67,9 @@ const CacheConfig = () => { const selectedFiles = type === 'playlist' ? files.filter((file) => file.split('_')[0] === 'playlist') - : files.filter((file) => file.split('_')[0] === 'album'); + : type === 'album' + ? files.filter((file) => file.split('_')[0] === 'album') + : files.filter((file) => file.split('_')[0] === 'artist'); return selectedFiles.forEach((file) => { const imagePath = path.join(imageCachePath, file); @@ -82,6 +85,7 @@ const CacheConfig = () => { } }); }); + notifyToast('success', `Cleared ${type} image cache`); }; return ( @@ -180,23 +184,18 @@ const CacheConfig = () => { Which cache would you like to clear? - - - + }