feat(offline): add offline mode link to login screen

- Add "Start in offline mode" link below login form
- Enable offline mode without authentication
- Navigate directly to local library when starting offline
- Add i18n strings for offline start link (en/es)
This commit is contained in:
vicrodh committed 2026-01-15 22:59:30 -06:00
1 parent 6bcb1fc7a6
commit 6e0d7486b0
4 files changed
+59 -4

No files matched your search

+42 -1
View File
@@ -1,6 +1,8 @@
<script lang="ts">
import { invoke } from '@tauri-apps/api/core';
import TitleBar from '../TitleBar.svelte';
import { t } from '$lib/i18n';
import { setManualOffline } from '$lib/stores/offlineStore';
interface UserInfo {
userName: string;
@@ -9,9 +11,10 @@
interface Props {
onLoginSuccess: (userInfo: UserInfo) => void;
onStartOffline?: () => void;
}
let { onLoginSuccess }: Props = $props();
let { onLoginSuccess, onStartOffline }: Props = $props();
let email = $state('');
let password = $state('');
@@ -128,6 +131,16 @@
isLoading = false;
}
}
async function handleStartOffline() {
try {
await setManualOffline(true);
onStartOffline?.();
} catch (err) {
console.error('Failed to enable offline mode:', err);
error = String(err);
}
}
</script>
<div class="login-wrapper">
@@ -203,6 +216,14 @@
QBZ requires an active Qobuz subscription.
Your credentials are sent directly to Qobuz and stored securely in your system's keyring.
</p>
<p class="offline-link">
<small>
<button type="button" class="link-button" onclick={handleStartOffline}>
{$t('offline.startWithoutLogin')}
</button>
</small>
</p>
{/if}
</div>
</div>
@@ -411,6 +432,26 @@
line-height: 1.5;
}
.offline-link {
margin-top: 16px;
text-align: center;
}
.link-button {
background: none;
border: none;
color: var(--text-muted);
cursor: pointer;
text-decoration: underline;
font-size: inherit;
padding: 0;
transition: color 150ms ease;
}
.link-button:hover {
color: var(--accent-primary);
}
.spinner {
width: 32px;
height: 32px;
+2 -1
View File
@@ -443,6 +443,7 @@
"someLocal": "Partially Available Offline",
"notAvailable": "Not Available Offline",
"trackNotAvailable": "This track is not available offline",
"featureDisabled": "This feature requires internet connection"
"featureDisabled": "This feature requires internet connection",
"startWithoutLogin": "Start in offline mode without logging in"
}
}
+2 -1
View File
@@ -443,6 +443,7 @@
"someLocal": "Parcialmente Disponible Offline",
"notAvailable": "No Disponible Offline",
"trackNotAvailable": "Esta pista no esta disponible offline",
"featureDisabled": "Esta funcion requiere conexion a internet"
"featureDisabled": "Esta funcion requiere conexion a internet",
"startWithoutLogin": "Iniciar en modo offline sin autenticacion"
}
}
+13 -1
View File
@@ -255,6 +255,7 @@
getStatus as getOfflineStatus,
isOffline as checkIsOffline,
getOfflineReason,
setManualOffline,
type OfflineStatus
} from '$lib/stores/offlineStore';
@@ -1203,6 +1204,17 @@
}
// Auth Handlers
async function handleStartOffline() {
// Enable manual offline mode and enter app without authentication
await setManualOffline(true);
setLoggedIn({
userName: 'Offline User',
subscription: 'Local Library Only'
});
navigateTo('library');
showToast('Started in offline mode', 'info');
}
async function handleLoginSuccess(info: UserInfo) {
setLoggedIn(info);
showToast(`Welcome, ${info.userName}!`, 'success');
@@ -1771,7 +1783,7 @@
</script>
{#if !isLoggedIn}
<LoginView onLoginSuccess={handleLoginSuccess} />
<LoginView onLoginSuccess={handleLoginSuccess} onStartOffline={handleStartOffline} />
{:else}
<div class="app">
<!-- Custom Title Bar (CSD) -->