fix(qr): add channels as key to remember block to fix add-channel rac…#4607
fix(qr): add channels as key to remember block to fix add-channel rac…#4607jamesarich merged 4 commits intomeshtastic:mainfrom
Conversation
…e condition The remember block on channelSet only keyed on shouldReplace, so it captured the empty initial ChannelSet before channelSetFlow emitted the device's actual channels. This caused "Add" mode to merge [] + [incoming] = [incoming], wiping the user's existing channels and LoRa config. Adding channels as a key forces recomputation when the real device channels load. Related: meshtastic#3464
|
|
Not sure why this double posted, and the CLA isn't showing in this message as signed, it was above. |
There was a problem hiding this comment.
Pull request overview
This PR fixes a critical race condition in the QR code channel scanning dialog that caused user data loss when adding channels. The bug occurred because the remember block computing the merged channel set was only keyed on shouldReplace, causing it to capture the empty initial ChannelSet() before the actual device channels loaded from the async StateFlow. This resulted in "Add" mode effectively doing [] + [incoming] = [incoming], wiping out existing channels and LoRa configuration.
Changes:
- Added
channelsas a key to therememberblock computingchannelSet, forcing recomputation when the real device channels load from the StateFlow
core/ui/src/main/kotlin/org/meshtastic/core/ui/qr/ScannedQrCodeDialog.kt
Outdated
Show resolved
Hide resolved
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4607 +/- ##
=====================================
Coverage 8.29% 8.29%
=====================================
Files 296 296
Lines 10782 10782
Branches 1666 1666
=====================================
Hits 894 894
Misses 9692 9692
Partials 196 196 ☔ View full report in Codecov by Sentry. |
…eDialog.kt Co-authored-by: Copilot <[email protected]> Signed-off-by: James Rich <[email protected]>
jamesarich
left a comment
There was a problem hiding this comment.
looks good, thanks for the fix
#4607) Signed-off-by: James Rich <[email protected]> Co-authored-by: James Rich <[email protected]> Co-authored-by: Copilot <[email protected]>
…e condition
The remember block on channelSet only keyed on shouldReplace, so it captured
the empty initial ChannelSet before channelSetFlow emitted the device's actual
channels. This caused "Add" mode to merge [] + [incoming] = [incoming], wiping
the user's existing channels and LoRa config. Adding channels as a key forces
recomputation when the real device channels load.
Related: #3464
And if you want to display the state before and after a change, you can use this table template:
Closes #4606