Fix adding channels#1513
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where adding multiple channels via QR code would only add one channel and not reflect the changes in the UI. The fix involves initializing the channel index counter outside the for loop and calling the channelPacket function to update the UI for each added channel.
Key Changes
- Moved index variable initialization outside the for loop to prevent channels from overwriting each other
- Added
channelPacketfunction call to update the UI with newly added channels
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
| } catch { | ||
| Logger.data.error("Failed to find a node MyInfo to save these channels to: \(error.localizedDescription, privacy: .public)") | ||
| guard let mutableChannels = myInfo.channels?.mutableCopy() as? NSMutableOrderedSet else { |
There was a problem hiding this comment.
Should it be mutable if we are not mutating it anywhere?
| } | ||
|
|
||
| // We are trying to add a channel so lets get the last index | ||
| myInfo = fetchedMyInfo[0] |
There was a problem hiding this comment.
We could use only the Set of channels instead of entire parent object. Maybe we can have an optional set of channels instead.
So var myInfo: MyInfoEntity! would become var myInfoChannels: NSOrderedSet?
What changed?
We now create the initial value for index i var outside the for loop so multiple cchannels dont try to overwrite each other. Also we call channel packet function to update the UI with new channels.
Why did it change?
Before adding multiple cahnnels via QR would only add one and this would not be reflected in the UI.
How is this tested?
Tested sending multiple qr codes from android to iOS
Screenshots/Videos (when applicable)
Checklist