feat(settings): add MusicBrainz cache clear button in Storage section
cc
This commit is contained in:
1 parent
dfbf64b1a4
commit
1cdf15ecf0
1 file changed
+30
-1
@@ -106,6 +106,7 @@
|
|||||||
// Lyrics cache state
|
// Lyrics cache state
|
||||||
let isClearingLyrics = $state(false);
|
let isClearingLyrics = $state(false);
|
||||||
let lyricsCacheStats = $state<{ entries: number; sizeBytes: number } | null>(null);
|
let lyricsCacheStats = $state<{ entries: number; sizeBytes: number } | null>(null);
|
||||||
|
let isClearingMusicBrainz = $state(false);
|
||||||
|
|
||||||
// Migration state
|
// Migration state
|
||||||
let showMigrationModal = $state(false);
|
let showMigrationModal = $state(false);
|
||||||
@@ -1492,6 +1493,19 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function handleClearMusicBrainzCache() {
|
||||||
|
if (isClearingMusicBrainz) return;
|
||||||
|
isClearingMusicBrainz = true;
|
||||||
|
try {
|
||||||
|
await invoke('musicbrainz_clear_cache');
|
||||||
|
console.log('MusicBrainz cache cleared');
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Failed to clear MusicBrainz cache:', err);
|
||||||
|
} finally {
|
||||||
|
isClearingMusicBrainz = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function formatBytes(bytes: number): string {
|
function formatBytes(bytes: number): string {
|
||||||
if (bytes === 0) return '0 B';
|
if (bytes === 0) return '0 B';
|
||||||
const k = 1024;
|
const k = 1024;
|
||||||
@@ -2162,7 +2176,7 @@
|
|||||||
{isClearing ? $t('settings.storage.clearing') : $t('actions.clear')}
|
{isClearing ? $t('settings.storage.clearing') : $t('actions.clear')}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="setting-row last">
|
<div class="setting-row">
|
||||||
<div class="setting-info">
|
<div class="setting-info">
|
||||||
<span class="setting-label">{$t('settings.lyrics.clearLyrics')}</span>
|
<span class="setting-label">{$t('settings.lyrics.clearLyrics')}</span>
|
||||||
<small class="setting-note">
|
<small class="setting-note">
|
||||||
@@ -2186,6 +2200,21 @@
|
|||||||
{isClearingLyrics ? $t('settings.storage.clearing') : $t('actions.clear')}
|
{isClearingLyrics ? $t('settings.storage.clearing') : $t('actions.clear')}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="setting-row last">
|
||||||
|
<div class="setting-info">
|
||||||
|
<span class="setting-label">MusicBrainz Cache</span>
|
||||||
|
<small class="setting-note">
|
||||||
|
Artist relationships, metadata enrichment
|
||||||
|
</small>
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
class="clear-btn"
|
||||||
|
onclick={handleClearMusicBrainzCache}
|
||||||
|
disabled={isClearingMusicBrainz}
|
||||||
|
>
|
||||||
|
{isClearingMusicBrainz ? $t('settings.storage.clearing') : $t('actions.clear')}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<!-- Flatpak Section (only shown when running in Flatpak) -->
|
<!-- Flatpak Section (only shown when running in Flatpak) -->
|
||||||
|
|||||||
Reference in new issue
Block a user