Skip to content

fix: skip unchanged server state and group updates#65

Merged
chrisuthe merged 1 commit intomainfrom
fix/skip-unchanged-server-state
Mar 8, 2026
Merged

fix: skip unchanged server state and group updates#65
chrisuthe merged 1 commit intomainfrom
fix/skip-unchanged-server-state

Conversation

@chrisuthe
Copy link
Copy Markdown
Owner

Summary

  • handleServerState and handleGroupUpdate in SendSpinProtocolHandler were unconditionally forwarding every received message to callbacks, triggering unnecessary StateFlow emissions and Compose UI recomposition even when values (group name, metadata, playback state) hadn't changed.
  • Added change detection by tracking lastMetadata, lastPlaybackState, and lastGroupInfo -- callbacks are now only invoked when the new value differs from the previous one.
  • Cached values are cleared on each new handshake (handleServerHello) so the first messages after connect/reconnect always propagate.

Test plan

  • Connect to a SendSpin server and verify metadata, playback state, and group name display correctly on first connect
  • Verify that repeated identical server/state messages (e.g., while paused) do not cause UI flicker or unnecessary recomposition
  • Disconnect and reconnect -- verify state updates propagate correctly after reconnection
  • Switch groups and verify group name updates correctly

@chrisuthe chrisuthe merged commit a23a8b6 into main Mar 8, 2026
…ry recomposition

handleServerState and handleGroupUpdate were unconditionally forwarding
every received message to callbacks, even when the values hadn't changed.
This caused unnecessary StateFlow emissions and Compose UI recomposition.

Track lastMetadata, lastPlaybackState, and lastGroupInfo and only forward
when the new value differs. Cached values are cleared on each new
handshake so the first post-connect messages always propagate.
@chrisuthe chrisuthe deleted the fix/skip-unchanged-server-state branch March 8, 2026 02:40
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