Skip to content

Slim PlayerViewModel: extract controller sync and playPause#2344

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

Slim PlayerViewModel: extract controller sync and playPause#2344
theovilardo merged 1 commit into
masterfrom
refactor/playerviewmodel-1

Conversation

@theovilardo

Copy link
Copy Markdown
Collaborator

Pass 8a - playPause + remote-queue reconciliation -> PlaybackDispatchStateHolder:

  • Move playPause (cast pause/resume, remote-queue realignment, local controller resume/fallback paths) plus its hasRemoteQueueItems and remoteQueueMatchesLocalQueue helpers. Every dependency and callback it needs already existed in the dispatch holder.

Pass 8b - media-controller sync cluster -> new MediaControllerSyncStateHolder:

  • Move the decomposed Player.Listener registrations (volume, playback state, media-item/timeline transitions incl. the EOT sleep timer and Telegram offline guard, tracks/metadata/shuffle/repeat), the initial controller-state snapshot, the queue snapshot rebuild with its timeline-signature dedupe, repeat-mode restore/flush, position sync, and the playback audio-metadata (format/bitrate/sample-rate) probing.
  • The holder owns the listener registry, transition/buffering/probe jobs and the PlaybackAudioMetadata flow; the ViewModel re-exposes playbackAudioMetadata and supplies VM-owned state through one ControllerSyncCallbacks bundle set at init.
  • ViewModel sheds the field-injected MediaMapper (now a holder ctor dep).
  • PlayerViewModelTest constructs the real sync holder wired to the same mocks so the repeat-mode restore test keeps covering the moved logic.

All public ViewModel signatures preserved as thin delegates; no UI files change. PlayerViewModel: 3,962 -> 3,118 lines.

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

Pass 8a - playPause + remote-queue reconciliation -> PlaybackDispatchStateHolder:
- Move playPause (cast pause/resume, remote-queue realignment, local
  controller resume/fallback paths) plus its hasRemoteQueueItems and
  remoteQueueMatchesLocalQueue helpers. Every dependency and callback it
  needs already existed in the dispatch holder.

Pass 8b - media-controller sync cluster -> new MediaControllerSyncStateHolder:
- Move the decomposed Player.Listener registrations (volume, playback
  state, media-item/timeline transitions incl. the EOT sleep timer and
  Telegram offline guard, tracks/metadata/shuffle/repeat), the initial
  controller-state snapshot, the queue snapshot rebuild with its
  timeline-signature dedupe, repeat-mode restore/flush, position sync,
  and the playback audio-metadata (format/bitrate/sample-rate) probing.
- The holder owns the listener registry, transition/buffering/probe jobs
  and the PlaybackAudioMetadata flow; the ViewModel re-exposes
  playbackAudioMetadata and supplies VM-owned state through one
  ControllerSyncCallbacks bundle set at init.
- ViewModel sheds the field-injected MediaMapper (now a holder ctor dep).
- PlayerViewModelTest constructs the real sync holder wired to the same
  mocks so the repeat-mode restore test keeps covering the moved logic.

All public ViewModel signatures preserved as thin delegates; no UI files
change. PlayerViewModel: 3,962 -> 3,118 lines.

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

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@theovilardo theovilardo merged commit 122805e into master Jun 13, 2026
4 checks 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