mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-06-18 09:05:24 -04:00
feat(network): add saved WiFi state to settings (#2648)
This commit is contained in:
@@ -69,6 +69,7 @@ Singleton {
|
||||
property bool changingPreference: false
|
||||
property string targetPreference: ""
|
||||
property var savedWifiNetworks: []
|
||||
readonly property int savedWifiStateApiVersion: 26
|
||||
property string connectionStatus: ""
|
||||
property string lastConnectionError: ""
|
||||
property bool passwordDialogShouldReopen: false
|
||||
@@ -309,17 +310,21 @@ Singleton {
|
||||
|
||||
if (state.wifiNetworks) {
|
||||
wifiNetworks = state.wifiNetworks;
|
||||
}
|
||||
|
||||
if (state.wifiNetworks || state.savedWifiNetworks) {
|
||||
const hasSavedWifiState = DMSService.apiVersion >= savedWifiStateApiVersion && Array.isArray(state.savedWifiNetworks);
|
||||
const sourceSavedNetworks = hasSavedWifiState ? state.savedWifiNetworks : (state.wifiNetworks || []).filter(network => network.saved);
|
||||
const saved = [];
|
||||
const mapping = {};
|
||||
for (const network of state.wifiNetworks) {
|
||||
if (network.saved) {
|
||||
saved.push({
|
||||
ssid: network.ssid,
|
||||
saved: true
|
||||
});
|
||||
for (const network of sourceSavedNetworks) {
|
||||
const normalized = Object.assign({}, network, {
|
||||
saved: true,
|
||||
outOfRange: hasSavedWifiState ? network.outOfRange === true : false
|
||||
});
|
||||
saved.push(normalized);
|
||||
if (network?.ssid)
|
||||
mapping[network.ssid] = network.ssid;
|
||||
}
|
||||
}
|
||||
savedConnections = saved;
|
||||
savedWifiNetworks = saved;
|
||||
@@ -596,6 +601,7 @@ Singleton {
|
||||
}
|
||||
wifiNetworks = updated;
|
||||
networksUpdated();
|
||||
Qt.callLater(() => refreshSavedWifiNetworks());
|
||||
}
|
||||
forgetSSID = "";
|
||||
});
|
||||
@@ -985,4 +991,11 @@ Singleton {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function refreshSavedWifiNetworks() {
|
||||
if (!networkAvailable)
|
||||
return;
|
||||
|
||||
getState();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user