refactor: optimize wifi network lookup by using map instead of array iteration, change cli command for connect
This commit is contained in:
parent
3cf3474957
commit
90e3deb589
1 changed files with 4 additions and 10 deletions
|
|
@ -120,7 +120,7 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wifiLogic.networks = Object.values(networksMap);
|
wifiLogic.networks = networksMap;
|
||||||
scanProcess.existingNetwork = {};
|
scanProcess.existingNetwork = {};
|
||||||
refreshIndicator.running = false;
|
refreshIndicator.running = false;
|
||||||
refreshIndicator.visible = false;
|
refreshIndicator.visible = false;
|
||||||
|
|
@ -182,13 +182,7 @@ Item {
|
||||||
wifiLogic.connectingSsid = params.ssid;
|
wifiLogic.connectingSsid = params.ssid;
|
||||||
|
|
||||||
// Find the target network in our networks data
|
// Find the target network in our networks data
|
||||||
let targetNetwork = null;
|
const targetNetwork = wifiLogic.networks[params.ssid];
|
||||||
for (let i = 0; i < wifiLogic.networks.length; ++i) {
|
|
||||||
if (wifiLogic.networks[i].ssid === params.ssid) {
|
|
||||||
targetNetwork = wifiLogic.networks[i];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if profile already exists using existing field
|
// Check if profile already exists using existing field
|
||||||
if (targetNetwork && targetNetwork.existing) {
|
if (targetNetwork && targetNetwork.existing) {
|
||||||
|
|
@ -220,7 +214,7 @@ Item {
|
||||||
id: disconnectProfileProcess
|
id: disconnectProfileProcess
|
||||||
property string connectionName: ""
|
property string connectionName: ""
|
||||||
running: false
|
running: false
|
||||||
command: ["nmcli", "connection", "down", "id", connectionName]
|
command: ["nmcli", "connection", "down", connectionName]
|
||||||
onRunningChanged: {
|
onRunningChanged: {
|
||||||
if (!running) {
|
if (!running) {
|
||||||
wifiLogic.refreshNetworks();
|
wifiLogic.refreshNetworks();
|
||||||
|
|
@ -527,7 +521,7 @@ Item {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
spacing: 4
|
spacing: 4
|
||||||
boundsBehavior: Flickable.StopAtBounds
|
boundsBehavior: Flickable.StopAtBounds
|
||||||
model: wifiLogic.networks
|
model: Object.values(wifiLogic.networks)
|
||||||
delegate: Item {
|
delegate: Item {
|
||||||
id: networkEntry
|
id: networkEntry
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue