Add manual offline mode settings and disable import in offline mode

- Disable import playlists button when offline (shows disabled state)
- Add Cast, immediate scrobbling, and accumulated scrobbling toggles
- These settings only appear when manual offline mode is enabled
- Add time limit note for accumulated scrobbling (Last.fm 2 week limit)
- Persist new settings in SQLite with proper migrations
- Add i18n strings for all new settings (en/es)
This commit is contained in:
vicrodh committed 2026-01-16 03:15:02 -06:00
1 parent 6f3bcfe1cb
commit f9ca1bd25e
7 files changed
+245 -8

No files matched your search

+16 -1
View File
@@ -511,7 +511,12 @@
<span>{$t('actions.refresh')}</span>
</button>
<button class="menu-item" onclick={() => handleMenuAction(onImportPlaylist ?? (() => {}))}>
<button
class="menu-item"
class:disabled={offlineStatus.isOffline}
onclick={() => !offlineStatus.isOffline && handleMenuAction(onImportPlaylist ?? (() => {}))}
title={offlineStatus.isOffline ? $t('offline.featureDisabled') : undefined}
>
<Import size={14} />
<span>{$t('playlist.import')}</span>
</button>
@@ -794,6 +799,16 @@
color: var(--accent-primary);
}
.menu-item.disabled {
opacity: 0.4;
cursor: not-allowed;
}
.menu-item.disabled:hover {
background: none;
color: var(--text-secondary);
}
.menu-item.has-submenu {
position: relative;
}
+79 -1
View File
@@ -34,6 +34,9 @@
getSettings as getOfflineSettings,
setManualOffline,
setShowPartialPlaylists,
setAllowCastWhileOffline,
setAllowImmediateScrobbling,
setAllowAccumulatedScrobbling,
checkNetwork,
type OfflineStatus,
type OfflineSettings
@@ -695,6 +698,30 @@
}
}
async function handleAllowCastChange(enabled: boolean) {
try {
await setAllowCastWhileOffline(enabled);
} catch (error) {
console.error('Failed to set allow cast while offline:', error);
}
}
async function handleAllowImmediateScrobblingChange(enabled: boolean) {
try {
await setAllowImmediateScrobbling(enabled);
} catch (error) {
console.error('Failed to set allow immediate scrobbling:', error);
}
}
async function handleAllowAccumulatedScrobblingChange(enabled: boolean) {
try {
await setAllowAccumulatedScrobbling(enabled);
} catch (error) {
console.error('Failed to set allow accumulated scrobbling:', error);
}
}
async function handleLanguageChange(lang: string) {
language = lang;
const localeCode = languageToLocale[lang];
@@ -1136,13 +1163,39 @@
</div>
<Toggle enabled={offlineSettings.manualOfflineMode} onchange={handleManualOfflineChange} />
</div>
<div class="setting-row last">
<div class="setting-row" class:last={!offlineSettings.manualOfflineMode}>
<div class="setting-info">
<span class="setting-label">{$t('offline.showPartialPlaylists')}</span>
<span class="setting-desc">{$t('offline.showPartialPlaylistsDesc')}</span>
</div>
<Toggle enabled={offlineSettings.showPartialPlaylists} onchange={handleShowPartialPlaylistsChange} />
</div>
<!-- Manual offline mode specific settings -->
{#if offlineSettings.manualOfflineMode}
<div class="setting-row">
<div class="setting-info">
<span class="setting-label">{$t('offline.allowCast')}</span>
<span class="setting-desc">{$t('offline.allowCastDesc')}</span>
</div>
<Toggle enabled={offlineSettings.allowCastWhileOffline} onchange={handleAllowCastChange} />
</div>
<div class="setting-row">
<div class="setting-info">
<span class="setting-label">{$t('offline.allowImmediateScrobbling')}</span>
<span class="setting-desc">{$t('offline.allowImmediateScrobblingDesc')}</span>
</div>
<Toggle enabled={offlineSettings.allowImmediateScrobbling} onchange={handleAllowImmediateScrobblingChange} />
</div>
<div class="setting-row last">
<div class="setting-info">
<span class="setting-label">{$t('offline.allowAccumulatedScrobbling')}</span>
<span class="setting-desc">{$t('offline.allowAccumulatedScrobblingDesc')}</span>
<small class="setting-note">{$t('offline.scrobbleTimeLimit')}</small>
</div>
<Toggle enabled={offlineSettings.allowAccumulatedScrobbling} onchange={handleAllowAccumulatedScrobblingChange} />
</div>
{/if}
</section>
<!-- Appearance Section -->
@@ -1768,6 +1821,31 @@
color: var(--text-muted);
}
.setting-info {
display: flex;
flex-direction: column;
gap: 2px;
flex: 1;
}
.setting-desc {
font-size: 12px;
color: var(--text-muted);
}
.setting-note {
font-size: 11px;
color: var(--text-muted);
opacity: 0.8;
margin-top: 4px;
}
.setting-row:has(.setting-note) {
height: auto;
min-height: 48px;
padding: 12px 0;
}
.setting-value {
font-size: 14px;
color: var(--text-muted);
+8 -1
View File
@@ -450,7 +450,14 @@
"available": "Available Offline",
"partiallyAvailable": "Partially Available",
"notAvailableOffline": "Not Available Offline",
"viewOnly": "View Only (Offline)"
"viewOnly": "View Only (Offline)",
"allowCast": "Allow Chromecast",
"allowCastDesc": "Enable Chromecast streaming while in manual offline mode",
"allowImmediateScrobbling": "Immediate Scrobbling",
"allowImmediateScrobblingDesc": "Send scrobbles to Last.fm immediately while in manual offline mode",
"allowAccumulatedScrobbling": "Accumulated Scrobbling",
"allowAccumulatedScrobblingDesc": "Queue scrobbles for later when back online",
"scrobbleTimeLimit": "Last.fm accepts scrobbles up to 2 weeks old"
},
"filter": {
"all": "All"
+8 -1
View File
@@ -450,7 +450,14 @@
"available": "Disponible Offline",
"partiallyAvailable": "Parcialmente Disponible",
"notAvailableOffline": "No Disponible Offline",
"viewOnly": "Solo Ver (Offline)"
"viewOnly": "Solo Ver (Offline)",
"allowCast": "Permitir Chromecast",
"allowCastDesc": "Habilitar streaming por Chromecast en modo offline manual",
"allowImmediateScrobbling": "Scrobbling Inmediato",
"allowImmediateScrobblingDesc": "Enviar scrobbles a Last.fm inmediatamente en modo offline manual",
"allowAccumulatedScrobbling": "Scrobbling Acumulado",
"allowAccumulatedScrobblingDesc": "Almacenar scrobbles para enviar cuando vuelvas a estar en linea",
"scrobbleTimeLimit": "Last.fm acepta scrobbles de hasta 2 semanas de antiguedad"
},
"filter": {
"all": "Todos"
+48
View File
@@ -33,6 +33,9 @@ export interface OfflineStatus {
export interface OfflineSettings {
manualOfflineMode: boolean;
showPartialPlaylists: boolean;
allowCastWhileOffline: boolean;
allowImmediateScrobbling: boolean;
allowAccumulatedScrobbling: boolean;
}
// Store state
@@ -45,6 +48,9 @@ let status: OfflineStatus = {
let settings: OfflineSettings = {
manualOfflineMode: false,
showPartialPlaylists: true,
allowCastWhileOffline: false,
allowImmediateScrobbling: false,
allowAccumulatedScrobbling: true,
};
let initialized = false;
@@ -188,6 +194,48 @@ export async function setShowPartialPlaylists(enabled: boolean): Promise<void> {
}
}
/**
* Set whether to allow Chromecast while in manual offline mode
*/
export async function setAllowCastWhileOffline(enabled: boolean): Promise<void> {
try {
await invoke('set_allow_cast_while_offline', { enabled });
settings.allowCastWhileOffline = enabled;
notifyListeners();
} catch (error) {
console.error('Failed to set allow cast while offline:', error);
throw error;
}
}
/**
* Set whether to allow immediate scrobbling to Last.fm in manual offline mode
*/
export async function setAllowImmediateScrobbling(enabled: boolean): Promise<void> {
try {
await invoke('set_allow_immediate_scrobbling', { enabled });
settings.allowImmediateScrobbling = enabled;
notifyListeners();
} catch (error) {
console.error('Failed to set allow immediate scrobbling:', error);
throw error;
}
}
/**
* Set whether to queue scrobbles for later submission when back online
*/
export async function setAllowAccumulatedScrobbling(enabled: boolean): Promise<void> {
try {
await invoke('set_allow_accumulated_scrobbling', { enabled });
settings.allowAccumulatedScrobbling = enabled;
notifyListeners();
} catch (error) {
console.error('Failed to set allow accumulated scrobbling:', error);
throw error;
}
}
/**
* Force refresh of offline status
*/