Skip to content

Fix adding channels#1513

Merged
RCGV1 merged 2 commits into
meshtastic:fix-qr-addingfrom
RCGV1:fix-add-qr
Dec 30, 2025
Merged

Fix adding channels#1513
RCGV1 merged 2 commits into
meshtastic:fix-qr-addingfrom
RCGV1:fix-add-qr

Conversation

@RCGV1

@RCGV1 RCGV1 commented Nov 26, 2025

Copy link
Copy Markdown
Member

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

  • My code adheres to the project's coding and style guidelines.
  • I have conducted a self-review of my code.
  • I have commented my code, particularly in complex areas.
  • I have verified whether these changes require an update to existing documentation or if new documentation is needed, and created an issue in the docs repo if applicable.
  • I have tested the change to ensure that it works as intended.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 channelPacket function 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 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@garthvh garthvh changed the base branch from main to 2.7.6 December 18, 2025 03:55
@garthvh garthvh changed the base branch from 2.7.6 to main December 18, 2025 03:56
@RCGV1 RCGV1 changed the base branch from main to fix-qr-adding December 30, 2025 17:30
@RCGV1 RCGV1 merged commit 2d226d7 into meshtastic:fix-qr-adding Dec 30, 2025
1 of 2 checks passed
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.

3 participants