fix:wifinetwork keep asking for pass

This commit is contained in:
Satoxyan
2025-03-20 09:37:21 +07:00
parent ad63420198
commit 968534c99a
@@ -143,28 +143,32 @@ const CurrentNetwork = () => {
onAccept: (self) => { onAccept: (self) => {
authLock = false; authLock = false;
networkAuth.revealChild = false; networkAuth.revealChild = false;
execAsync(['nmcli', 'connection', 'delete', connectAttempt]) execAsync(['nmcli', 'device', 'wifi', 'connect', connectAttempt, 'password', self.text])
.catch(print) .catch(print);
.then(() => execAsync(['nmcli', 'device', 'wifi', 'connect', connectAttempt, 'password', self.text])
.catch(print));
} }
}) })
] ]
}), }),
setup: (self) => self.hook(Network, (self) => { setup: (self) => self.hook(Network, (self) => {
if (Network.wifi.state == 'failed' || Network.wifi.state == 'need_auth') { execAsync(['nmcli', '-g', 'NAME', 'connection', 'show'])
authLock = true; .then((savedConnections) => {
connectAttempt = Network.wifi.ssid; const savedSSIDs = savedConnections.split('\n');
self.revealChild = true; if (Network.wifi.state == 'failed' ||
if (timeoutId) { (Network.wifi.state == 'need_auth' && !savedSSIDs.includes(Network.wifi.ssid))) {
clearTimeout(timeoutId); authLock = true;
connectAttempt = Network.wifi.ssid;
self.revealChild = true;
if (timeoutId) {
clearTimeout(timeoutId);
}
timeoutId = setTimeout(() => {
authLock = false;
self.revealChild = false;
Network.wifi.state = 'activated';
}, 20000); // 20 seconds timeout
}
} }
timeoutId = setTimeout(() => { ).catch(print);
authLock = false;
self.revealChild = false;
Network.wifi.state = 'activated';
}, 20000); // 20 seconds timeout
}
}), }),
}); });
const actualContent = Box({ const actualContent = Box({