Skip to content

Slim PlayerViewModel: extract selection actions and playback dispatch…#2340

Merged
theovilardo merged 1 commit into
masterfrom
refactor/playerviewmodel-1
Jun 12, 2026
Merged

Slim PlayerViewModel: extract selection actions and playback dispatch…#2340
theovilardo merged 1 commit into
masterfrom
refactor/playerviewmodel-1

Conversation

@theovilardo

Copy link
Copy Markdown
Collaborator

… core

Pass 6 - multi-selection batch actions -> MultiSelectionStateHolder:

  • Move the songs/albums/genres play/queue/play-next trios, like/unlike, ZIP share, and album/genre song resolution out of the ViewModel.
  • Deduplicate while moving: the album and genre trios collapse into shared launchAlbumSelectionAction/launchGenreSelectionAction helpers and like/unlike into one updateFavoritesForSelection. Toast strings, ordering, and clearSelection timing preserved verbatim.
  • Holder gains MusicRepository + @ApplicationContext ctor deps; ViewModel supplies playback/toast collaborators via SelectionActionCallbacks.
  • Remove dead queueAndPlaySelectedAlbums (zero callers).

Pass 7 - playback dispatch core -> new PlaybackDispatchStateHolder:

  • Move both showAndPlaySong overloads, library/favorites full-queue playback with its job/token staleness machinery, playSongs, playSongsShuffled, internalPlaySongs, queue-segment batching, song hydration, playExternalUri, the shuffle-all tile entry point, loadAndPlaySong, the preparing-song pill state, and addSongToQueue/addSongNextToQueue.
  • @ViewModelScoped holder injects its 13 @singleton deps directly; ViewModel-owned state (controller, UI state, sheet, toasts, transition job) crosses one PlaybackDispatchCallbacks bundle set at init.
  • ViewModel ctor: +playbackDispatchStateHolder, -appShortcutManager, -externalMediaStateHolder (both now unused there).
  • PlayerViewModelTest constructs the real dispatch holder wired to the same mocks so end-to-end playback tests keep covering the moved logic.

All public ViewModel signatures are preserved as thin delegates, so no UI files change. PlayerViewModel: 5,061 -> 3,962 lines.

Verified: compileDebugKotlin, PlayerViewModelTest, PlayerViewModelHydrationTest, QueueStateHolderTest, PlaybackStateHolderTest.

… core

Pass 6 - multi-selection batch actions -> MultiSelectionStateHolder:
- Move the songs/albums/genres play/queue/play-next trios, like/unlike,
  ZIP share, and album/genre song resolution out of the ViewModel.
- Deduplicate while moving: the album and genre trios collapse into shared
  launchAlbumSelectionAction/launchGenreSelectionAction helpers and
  like/unlike into one updateFavoritesForSelection. Toast strings,
  ordering, and clearSelection timing preserved verbatim.
- Holder gains MusicRepository + @ApplicationContext ctor deps; ViewModel
  supplies playback/toast collaborators via SelectionActionCallbacks.
- Remove dead queueAndPlaySelectedAlbums (zero callers).

Pass 7 - playback dispatch core -> new PlaybackDispatchStateHolder:
- Move both showAndPlaySong overloads, library/favorites full-queue
  playback with its job/token staleness machinery, playSongs,
  playSongsShuffled, internalPlaySongs, queue-segment batching, song
  hydration, playExternalUri, the shuffle-all tile entry point,
  loadAndPlaySong, the preparing-song pill state, and
  addSongToQueue/addSongNextToQueue.
- @ViewModelScoped holder injects its 13 @singleton deps directly;
  ViewModel-owned state (controller, UI state, sheet, toasts, transition
  job) crosses one PlaybackDispatchCallbacks bundle set at init.
- ViewModel ctor: +playbackDispatchStateHolder, -appShortcutManager,
  -externalMediaStateHolder (both now unused there).
- PlayerViewModelTest constructs the real dispatch holder wired to the
  same mocks so end-to-end playback tests keep covering the moved logic.

All public ViewModel signatures are preserved as thin delegates, so no UI
files change. PlayerViewModel: 5,061 -> 3,962 lines.

Verified: compileDebugKotlin, PlayerViewModelTest,
PlayerViewModelHydrationTest, QueueStateHolderTest, PlaybackStateHolderTest.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@theovilardo theovilardo merged commit b5431ac into master Jun 12, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant