clear queue on navigation
This commit is contained in:
parent
830155c14a
commit
a6b27fbfc3
4 changed files with 54 additions and 0 deletions
16
index.html
16
index.html
|
|
@ -2997,6 +2997,22 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="settings-group">
|
||||
<div class="setting-item">
|
||||
<div class="info">
|
||||
<span class="label">Close Queue on Navigation</span>
|
||||
<span class="description"
|
||||
>Close the queue panel when navigating back or to a new page (useful for
|
||||
mobile)</span
|
||||
>
|
||||
</div>
|
||||
<label class="toggle-switch">
|
||||
<input type="checkbox" id="queue-close-on-navigation-toggle" />
|
||||
<span class="slider"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="settings-tab-content" id="settings-tab-scrobbling">
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import {
|
|||
downloadQualitySettings,
|
||||
sidebarSettings,
|
||||
pwaUpdateSettings,
|
||||
queueBehaviorSettings,
|
||||
} from './storage.js';
|
||||
import { UIRenderer } from './ui.js';
|
||||
import { Player } from './player.js';
|
||||
|
|
@ -1810,6 +1811,11 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
return;
|
||||
}
|
||||
|
||||
// Close side panel (queue/lyrics) on navigation if setting is enabled
|
||||
if (queueBehaviorSettings.shouldCloseOnNavigation()) {
|
||||
sidePanelManager.close();
|
||||
}
|
||||
|
||||
await router();
|
||||
updateTabTitle(player);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import {
|
|||
contentBlockingSettings,
|
||||
musicProviderSettings,
|
||||
analyticsSettings,
|
||||
queueBehaviorSettings,
|
||||
} from './storage.js';
|
||||
import { audioContextManager, EQ_PRESETS } from './audio-context.js';
|
||||
import { getButterchurnPresets } from './visualizers/butterchurn.js';
|
||||
|
|
@ -1532,6 +1533,15 @@ export function initializeSettings(scrobbler, player, api, ui) {
|
|||
});
|
||||
}
|
||||
|
||||
// Queue Close on Navigation Toggle
|
||||
const queueCloseOnNavigationToggle = document.getElementById('queue-close-on-navigation-toggle');
|
||||
if (queueCloseOnNavigationToggle) {
|
||||
queueCloseOnNavigationToggle.checked = queueBehaviorSettings.shouldCloseOnNavigation();
|
||||
queueCloseOnNavigationToggle.addEventListener('change', (e) => {
|
||||
queueBehaviorSettings.setCloseOnNavigation(e.target.checked);
|
||||
});
|
||||
}
|
||||
|
||||
// Compact Artist Toggle
|
||||
const compactArtistToggle = document.getElementById('compact-artist-toggle');
|
||||
if (compactArtistToggle) {
|
||||
|
|
|
|||
|
|
@ -2101,6 +2101,28 @@ export const musicProviderSettings = {
|
|||
},
|
||||
};
|
||||
|
||||
export const queueBehaviorSettings = {
|
||||
STORAGE_KEY: 'queue-close-on-navigation',
|
||||
|
||||
shouldCloseOnNavigation() {
|
||||
try {
|
||||
// Default to true on mobile, false on desktop
|
||||
const saved = localStorage.getItem(this.STORAGE_KEY);
|
||||
if (saved === null) {
|
||||
// Auto-detect: default to true for mobile/touch devices
|
||||
return window.matchMedia('(pointer: coarse)').matches;
|
||||
}
|
||||
return saved === 'true';
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
setCloseOnNavigation(enabled) {
|
||||
localStorage.setItem(this.STORAGE_KEY, enabled ? 'true' : 'false');
|
||||
},
|
||||
};
|
||||
|
||||
export const contentBlockingSettings = {
|
||||
BLOCKED_ARTISTS_KEY: 'blocked-artists',
|
||||
BLOCKED_TRACKS_KEY: 'blocked-tracks',
|
||||
|
|
|
|||
Loading…
Reference in a new issue