Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

luci-app-usteer: filter repeated SSIDs in config #6912

Merged
merged 1 commit into from
Feb 15, 2024

Conversation

McGiverGim
Copy link
Contributor

When the SSID name was the same in different radio, they appear repeated in the options. This commit filter them.

Signed-off-by: Miguel Angel Mulero Martinez

This change was after a discussion in of #6908

When the SSID name was the same in different radio, they appear repeated in the options. This commit filter them.

Signed-off-by: Miguel Angel Mulero Martinez <migmul@gmail.com>
@systemcrash
Copy link
Contributor

Could you walk me through what the change does please?

@McGiverGim
Copy link
Contributor Author

This UI element contains the list of wireless SSIDs available. When the 2.4 and 5 GHz networks have the same SSID, the name appears twice in the list.
This commit filters them to insert only once each SSID name in the list of SSIDs available.

@systemcrash
Copy link
Contributor

Sorry, I wasn't clear. I meant the if conditions now:

			if (wifiNetwork.getSSID() && (!o.keylist || o.keylist.indexOf(wifiNetwork.getSSID()) === -1)) {
				o.value(wifiNetwork.getSSID())
			}

I just had to stare at it for another minute to parse it :)

@systemcrash
Copy link
Contributor

Does the change work for you, @Ramon00 ?

@McGiverGim
Copy link
Contributor Author

I arrived to the condition after testing and looking into the debugger...

  • wifiNetwork.getSSID() -> In the list of wifi networks, they appear some that don't have SSID. In my case, I have a 802.11s mesh network, this is in the list, but this method does not return a SSID, for this reason I verify it.
  • !o.keylist -> What I want to check, is if the SSID was added before to the UI element or not. This method verifies that the list of the UI is not empty. I've verified that the list, after initializing the UI, is not an empty array, simply is not initialized, so that is what this checks.
  • o.keylist.indexOf(wifiNetwork.getSSID()) === -1)) -> When the list is not empty, this checks if the SSID was added before or not.

@systemcrash
Copy link
Contributor

!o.keylist -> ... This method verifies that the list of the UI is not empty. I've verified that the list, after initializing the UI, is not an empty array, simply is not initialized, so that is what this checks.

I read the code as: This method verifies that the list of the UI is empty (in which case it is safe to add any SSID, the first), and

o.keylist.indexOf(wifiNetwork.getSSID()) === -1)) -> When the list is not empty, this checks if the SSID was added before or not.

I read the code as: When the list is not empty, this returns true when the SSID is NOT already in the list

This is your intention, I guess - because that's what seems to me would be appropriate here.

@Ramon00
Copy link
Contributor

Ramon00 commented Feb 15, 2024

I tested it and it for me it works fine.

@systemcrash systemcrash merged commit 2841d28 into openwrt:master Feb 15, 2024
5 checks passed
@systemcrash
Copy link
Contributor

Ok. Thank you @McGiverGim and @Ramon00

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