fix: skip unchanged server state and group updates#65
Merged
Conversation
…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.
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
handleServerStateandhandleGroupUpdateinSendSpinProtocolHandlerwere unconditionally forwarding every received message to callbacks, triggering unnecessaryStateFlowemissions and Compose UI recomposition even when values (group name, metadata, playback state) hadn't changed.lastMetadata,lastPlaybackState, andlastGroupInfo-- callbacks are now only invoked when the new value differs from the previous one.handleServerHello) so the first messages after connect/reconnect always propagate.Test plan
server/statemessages (e.g., while paused) do not cause UI flicker or unnecessary recomposition