Skip to content

Preserve Organize form across album refetches

jedmund requested to merge jedmund/fix-organize-reset into main

Summary

Fixes a bug where the Organize form (and the selected recommendation in the left pane) would revert to defaults when the currently-playing track ended and the next one began.

Root cause

The reset $effect blocks in SortForm.svelte (lines 34-42) and RecommendationList.svelte (lines 31-43) unconditionally rewrote their form state whenever the album prop's reference changed — not just when the user actually switched to a different album.

During playback, audio-element error events (common around track transitions, especially on the NFS-mounted share) trigger handleAudioError in +page.svelte, which calls fetchAlbum($currentAlbum.id) to recover. That refetch replaces $currentAlbum with a new object reference for the same album, which caused both effects to re-run and clobber the user's selection.

Fix

Gate both resets on album.id/albumId actually changing, so refetches of the same album are no-ops and user edits survive.

Test plan

  • pnpm run build passes
  • Open an album, select a recommendation, let the current track end → Organize form retains recommendation values, selected recommendation stays selected
  • Switch to a different album → form correctly resets to that album's defaults
  • Manually edit fields, let the current track end → edits persist

Merge request reports

Loading