From 90e3deb589a9cad3fd4616f267e545c6d995fd81 Mon Sep 17 00:00:00 2001 From: JPratama7 Date: Sun, 3 Aug 2025 21:27:49 +0700 Subject: [PATCH] refactor: optimize wifi network lookup by using map instead of array iteration, change cli command for connect --- Widgets/Sidebar/Panel/WifiPanel.qml | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/Widgets/Sidebar/Panel/WifiPanel.qml b/Widgets/Sidebar/Panel/WifiPanel.qml index 6002551..4fc5b11 100644 --- a/Widgets/Sidebar/Panel/WifiPanel.qml +++ b/Widgets/Sidebar/Panel/WifiPanel.qml @@ -120,7 +120,7 @@ Item { } } } - wifiLogic.networks = Object.values(networksMap); + wifiLogic.networks = networksMap; scanProcess.existingNetwork = {}; refreshIndicator.running = false; refreshIndicator.visible = false; @@ -182,13 +182,7 @@ Item { wifiLogic.connectingSsid = params.ssid; // Find the target network in our networks data - let targetNetwork = null; - for (let i = 0; i < wifiLogic.networks.length; ++i) { - if (wifiLogic.networks[i].ssid === params.ssid) { - targetNetwork = wifiLogic.networks[i]; - break; - } - } + const targetNetwork = wifiLogic.networks[params.ssid]; // Check if profile already exists using existing field if (targetNetwork && targetNetwork.existing) { @@ -220,7 +214,7 @@ Item { id: disconnectProfileProcess property string connectionName: "" running: false - command: ["nmcli", "connection", "down", "id", connectionName] + command: ["nmcli", "connection", "down", connectionName] onRunningChanged: { if (!running) { wifiLogic.refreshNetworks(); @@ -527,7 +521,7 @@ Item { anchors.fill: parent spacing: 4 boundsBehavior: Flickable.StopAtBounds - model: wifiLogic.networks + model: Object.values(wifiLogic.networks) delegate: Item { id: networkEntry