feat: persist shuffle and repeat state across reloads/updates

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
HoneyandClaude Sonnet 4.6 committed 2026-04-28 09:55:32 +02:00
1 parent c8c3670ca0
commit d9b9151f50
2 files changed
+21 -10

No files matched your search

+16 -9
View File
@@ -144,23 +144,30 @@ export function onEnded() {
nextSong();
}
export function toggleShuffle() {
S.shuffle = !S.shuffle;
document.getElementById('btn-shuffle').classList.toggle('active', S.shuffle);
export function _applyShuffleRepeat() {
document.getElementById('btn-shuffle')?.classList.toggle('active', S.shuffle);
document.getElementById('np-shuffle-btn')?.classList.toggle('active', S.shuffle);
document.getElementById('badge-shuffle')?.classList.toggle('on', S.shuffle);
}
export function toggleRepeat() {
S.repeat = S.repeat === false ? 'all' : S.repeat === 'all' ? 'one' : false;
document.getElementById('btn-repeat').classList.toggle('active', S.repeat !== false);
document.getElementById('btn-repeat').classList.toggle('repeat-one', S.repeat === 'one');
document.getElementById('btn-repeat')?.classList.toggle('active', S.repeat !== false);
document.getElementById('btn-repeat')?.classList.toggle('repeat-one', S.repeat === 'one');
const nb = document.getElementById('np-repeat-btn');
if(nb) { nb.classList.toggle('active', S.repeat !== false); nb.classList.toggle('repeat-one', S.repeat === 'one'); }
const badge = document.getElementById('badge-repeat');
if(badge) { badge.classList.toggle('on', S.repeat !== false); badge.textContent = S.repeat === 'one' ? '🔂 Einmal' : '🔁 Repeat'; }
}
export function toggleShuffle() {
S.shuffle = !S.shuffle;
localStorage.setItem('ns_shuffle', S.shuffle ? '1' : '0');
_applyShuffleRepeat();
}
export function toggleRepeat() {
S.repeat = S.repeat === false ? 'all' : S.repeat === 'all' ? 'one' : false;
localStorage.setItem('ns_repeat', S.repeat === false ? '0' : S.repeat);
_applyShuffleRepeat();
}
// ─── RADIO ───
export function _applyRadioBtn() {
const btn = document.getElementById('btn-radio-mode');