From 3a9bfd08a968988da029119453fd2a2c22939d0e Mon Sep 17 00:00:00 2001 From: Drew Ansbacher Date: Mon, 22 Nov 2021 15:58:59 -0700 Subject: [PATCH] remove wifi on failure --- ui/src/app/pages/server-routes/wifi/wifi.page.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/ui/src/app/pages/server-routes/wifi/wifi.page.ts b/ui/src/app/pages/server-routes/wifi/wifi.page.ts index 134138d00..b06445fef 100644 --- a/ui/src/app/pages/server-routes/wifi/wifi.page.ts +++ b/ui/src/app/pages/server-routes/wifi/wifi.page.ts @@ -154,12 +154,20 @@ export class WifiPage { } } - private async confirmWifi (ssid: string): Promise { + private async confirmWifi (ssid: string, deleteOnFailure = false): Promise { const timeout = 4000 const maxAttempts = 5 let attempts = 0 while (attempts < maxAttempts) { + if (attempts > maxAttempts) { + this.presentToastFail() + if (deleteOnFailure) { + this.wifi.ssids = this.wifi.ssids.filter(s => s !== ssid) + } + break + } + try { const start = new Date().valueOf() await this.getWifi(timeout) @@ -171,9 +179,6 @@ export class WifiPage { attempts++ const diff = end - start await pauseFor(Math.max(1000, timeout - diff)) - if (attempts === maxAttempts) { - this.presentToastFail() - } } } catch (e) { attempts++ @@ -296,7 +301,7 @@ export class WifiPage { connect: true, }) - await this.confirmWifi(ssid) + await this.confirmWifi(ssid, true) } catch (e) { this.errToast.present(e)