fix(logic): context creation should NOT depend on autoplay setting

CRITICAL LOGIC FIX:

The autoplay setting was misunderstood. Corrected behavior:

BEFORE (wrong):
- Setting controls whether context is created
- 'continue' = create context
- 'track_only' = clear context

AFTER (correct):
- Context is ALWAYS created when playing from a source (album/playlist)
- Stack icon ALWAYS appears
- Setting only affects what happens at END of track:
  - 'continue' = play next track in context
  - 'track_only' = stop after current track

Why this makes sense:
- You're playing from an album = that's the context
- Stack icon shows the origin (informative)
- Setting controls continuation behavior (not context existence)

Also:
- Added logging to handleAutoplayModeChange
- Will investigate why setting doesn't persist

cp
This commit is contained in:
vicrodh committed 2026-01-18 03:09:57 -06:00
1 parent f69a7ab461
commit 17cd6f0ae2
2 files changed
+16 -24

No files matched your search

+3 -1
View File
@@ -1120,11 +1120,13 @@
} }
async function handleAutoplayModeChange(mode: AutoplayMode) { async function handleAutoplayModeChange(mode: AutoplayMode) {
console.log('[Settings] Changing autoplay mode to:', mode);
try { try {
await setAutoplayMode(mode); await setAutoplayMode(mode);
autoplayMode = mode; autoplayMode = mode;
console.log('[Settings] Autoplay mode saved successfully');
} catch (err) { } catch (err) {
console.error('Failed to set autoplay mode:', err); console.error('[Settings] Failed to set autoplay mode:', err);
showToast('Failed to save autoplay preference', 'error'); showToast('Failed to save autoplay preference', 'error');
} }
} }
+13 -23
View File
@@ -598,32 +598,22 @@
async function handleAlbumTrackPlay(track: Track) { async function handleAlbumTrackPlay(track: Track) {
console.log('Playing album track:', track); console.log('Playing album track:', track);
// Check autoplay preference and create/clear context // ALWAYS create context when playing from an album
const prefs = getCachedPreferences(); // The setting only affects menu options visibility, not implicit behavior
console.log('[Album] Autoplay preference:', prefs.autoplay_mode);
if (selectedAlbum?.tracks) { if (selectedAlbum?.tracks) {
const trackIndex = selectedAlbum.tracks.findIndex(t => t.id === track.id); const trackIndex = selectedAlbum.tracks.findIndex(t => t.id === track.id);
console.log('[Album] Track index:', trackIndex, 'of', selectedAlbum.tracks.length); const trackIds = selectedAlbum.tracks.map(t => t.id);
if (prefs.autoplay_mode === 'continue') { console.log('[Album] Creating context with', trackIds.length, 'tracks, starting at', trackIndex);
// Create album context await setPlaybackContext(
const trackIds = selectedAlbum.tracks.map(t => t.id); 'album',
console.log('[Album] Creating context with', trackIds.length, 'tracks, starting at', trackIndex); selectedAlbum.id,
await setPlaybackContext( selectedAlbum.title,
'album', 'qobuz',
selectedAlbum.id, trackIds,
selectedAlbum.title, trackIndex >= 0 ? trackIndex : 0
'qobuz', );
trackIds, console.log('[Album] Context created - stack icon should appear');
trackIndex >= 0 ? trackIndex : 0
);
console.log('[Album] Context created for continuous playback');
} else {
// Clear context for single track playback
await clearPlaybackContext();
console.log('[Album] Context cleared for single track playback');
}
} else { } else {
console.log('[Album] No album tracks found, cannot create context'); console.log('[Album] No album tracks found, cannot create context');
} }