fix: first channel toast uses cache channel count#509
Merged
piotr-iohk merged 1 commit intomasterfrom Mar 26, 2026
Merged
Conversation
Made-with: Cursor
0993667 to
1b970b1
Compare
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
pwltr
approved these changes
Mar 26, 2026
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.
Description
This PR fixes a race condition where the "Spending balance ready" toast (
SpendingBalanceReadyToast) would not appear after the user's first Lightning channel becomes ready.Bug: When a
.channelReadyevent fires, thechannelCachedictionary is already updated with the new channel, butlightningService.channels(backed bycachedChannels) may still be empty because it hasn't been refreshed yet. The old code only checkedchannels?.count == 1, so ifchannelswas still empty (count 0), the toast was suppressed — even though this was genuinely the first channel.Fix: Introduce
FirstChannelToastPolicythat checksmax(channelCacheCount, publishedChannelsCount) == 1, so the toast shows if either data source reports exactly one channel. Both counts are read in a singleMainActor.runblock to ensure a consistent snapshot.Unit tests cover the key scenarios: cache ahead of published (the bug), both in sync, multiple channels, and zero channels.
Linked Issues/Tasks
N/A
Screenshot / Video
N/A