mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-04-04 14:29:45 +00:00
remove wifi on failure
This commit is contained in:
committed by
Aiden McClelland
parent
fee358918a
commit
3a9bfd08a9
@@ -154,12 +154,20 @@ export class WifiPage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async confirmWifi (ssid: string): Promise<void> {
|
private async confirmWifi (ssid: string, deleteOnFailure = false): Promise<void> {
|
||||||
const timeout = 4000
|
const timeout = 4000
|
||||||
const maxAttempts = 5
|
const maxAttempts = 5
|
||||||
let attempts = 0
|
let attempts = 0
|
||||||
|
|
||||||
while (attempts < maxAttempts) {
|
while (attempts < maxAttempts) {
|
||||||
|
if (attempts > maxAttempts) {
|
||||||
|
this.presentToastFail()
|
||||||
|
if (deleteOnFailure) {
|
||||||
|
this.wifi.ssids = this.wifi.ssids.filter(s => s !== ssid)
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const start = new Date().valueOf()
|
const start = new Date().valueOf()
|
||||||
await this.getWifi(timeout)
|
await this.getWifi(timeout)
|
||||||
@@ -171,9 +179,6 @@ export class WifiPage {
|
|||||||
attempts++
|
attempts++
|
||||||
const diff = end - start
|
const diff = end - start
|
||||||
await pauseFor(Math.max(1000, timeout - diff))
|
await pauseFor(Math.max(1000, timeout - diff))
|
||||||
if (attempts === maxAttempts) {
|
|
||||||
this.presentToastFail()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
attempts++
|
attempts++
|
||||||
@@ -296,7 +301,7 @@ export class WifiPage {
|
|||||||
connect: true,
|
connect: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
await this.confirmWifi(ssid)
|
await this.confirmWifi(ssid, true)
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.errToast.present(e)
|
this.errToast.present(e)
|
||||||
|
|||||||
Reference in New Issue
Block a user