|
@ -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(); |
|
|
const imageCachePath = getImageCachePath(); |
|
|
fs.readdir(imageCachePath, (err, files) => { |
|
|
fs.readdir(imageCachePath, (err, files) => { |
|
|
if (err) { |
|
|
if (err) { |
|
@ -66,7 +67,9 @@ const CacheConfig = () => { |
|
|
const selectedFiles = |
|
|
const selectedFiles = |
|
|
type === 'playlist' |
|
|
type === 'playlist' |
|
|
? files.filter((file) => file.split('_')[0] === '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) => { |
|
|
return selectedFiles.forEach((file) => { |
|
|
const imagePath = path.join(imageCachePath, file); |
|
|
const imagePath = path.join(imageCachePath, file); |
|
@ -82,6 +85,7 @@ const CacheConfig = () => { |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
|
|
|
notifyToast('success', `Cleared ${type} image cache`); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
return ( |
|
|
return ( |
|
@ -180,23 +184,18 @@ const CacheConfig = () => { |
|
|
<Popover> |
|
|
<Popover> |
|
|
Which cache would you like to clear? |
|
|
Which cache would you like to clear? |
|
|
<ButtonToolbar> |
|
|
<ButtonToolbar> |
|
|
<Button appearance="primary" size="sm" onClick={handleClearSongCache}> |
|
|
<Button size="sm" onClick={handleClearSongCache}> |
|
|
Songs |
|
|
Songs |
|
|
</Button> |
|
|
</Button> |
|
|
<Button |
|
|
<Button size="sm" onClick={() => handleClearImageCache('playlist')}> |
|
|
appearance="primary" |
|
|
|
|
|
size="sm" |
|
|
|
|
|
onClick={() => handleClearImageCache('playlist')} |
|
|
|
|
|
> |
|
|
|
|
|
Playlist images |
|
|
Playlist images |
|
|
</Button> |
|
|
</Button> |
|
|
<Button |
|
|
<Button size="sm" onClick={() => handleClearImageCache('album')}> |
|
|
appearance="primary" |
|
|
|
|
|
size="sm" |
|
|
|
|
|
onClick={() => handleClearImageCache('album')} |
|
|
|
|
|
> |
|
|
|
|
|
Album images |
|
|
Album images |
|
|
</Button> |
|
|
</Button> |
|
|
|
|
|
<Button size="sm" onClick={() => handleClearImageCache('artist')}> |
|
|
|
|
|
Artist images |
|
|
|
|
|
</Button> |
|
|
</ButtonToolbar> |
|
|
</ButtonToolbar> |
|
|
</Popover> |
|
|
</Popover> |
|
|
} |
|
|
} |
|
|