feat(offline): disable external services when offline

- DownloadButton: show CloudOff icon and disable when offline
- LyricsStore: skip fetching and show "unavailable offline" message
- LocalLibraryView: skip artist image fetching from Qobuz/Discogs
- PlaylistImportModal: disable import with warning when offline
This commit is contained in:
vicrodh committed 2026-01-15 23:07:16 -06:00
1 parent 6e0d7486b0
commit 4891b9bcbc
4 files changed
+112 -5

No files matched your search

+39 -2
View File
@@ -1,5 +1,10 @@
<script lang="ts">
import { Download, Check, Loader, AlertCircle } from 'lucide-svelte';
import { Download, Check, Loader, AlertCircle, CloudOff } from 'lucide-svelte';
import { t } from '$lib/i18n';
import {
subscribe as subscribeOffline,
isOffline as checkIsOffline
} from '$lib/stores/offlineStore';
type DownloadStatus = 'none' | 'queued' | 'downloading' | 'ready' | 'failed';
@@ -19,9 +24,24 @@
onRemove
}: Props = $props();
// Offline state
let isOffline = $state(checkIsOffline());
$effect(() => {
const unsubscribe = subscribeOffline(() => {
isOffline = checkIsOffline();
});
return unsubscribe;
});
function handleClick(e: MouseEvent) {
e.stopPropagation();
// Don't allow new downloads when offline
if (isOffline && (status === 'none' || status === 'failed')) {
return;
}
if (status === 'none' || status === 'failed') {
onDownload?.();
} else if (status === 'ready') {
@@ -30,6 +50,10 @@
}
const title = $derived(() => {
// Show offline message when trying to download while offline
if (isOffline && (status === 'none' || status === 'failed')) {
return $t('offline.featureDisabled');
}
switch (status) {
case 'none': return 'Download for offline';
case 'queued': return 'Queued for download';
@@ -39,6 +63,11 @@
default: return '';
}
});
// Disable button when offline and not already downloaded
const isDisabled = $derived(
status === 'queued' || (isOffline && status !== 'ready')
);
</script>
<button
@@ -46,9 +75,10 @@
class:downloading={status === 'downloading' || status === 'queued'}
class:ready={status === 'ready'}
class:failed={status === 'failed'}
class:offline={isOffline && status !== 'ready'}
onclick={handleClick}
title={title()}
disabled={status === 'queued'}
disabled={isDisabled}
>
{#if status === 'ready'}
<Check {size} />
@@ -58,6 +88,8 @@
</div>
{:else if status === 'failed'}
<AlertCircle {size} />
{:else if isOffline}
<CloudOff {size} />
{:else}
<Download {size} />
{/if}
@@ -105,6 +137,11 @@
color: var(--accent-primary);
}
.download-button.offline {
color: var(--text-muted);
opacity: 0.5;
}
.progress-ring {
position: relative;
display: flex;