From f92e0988d3afda527b9f9402b9e7ae7c233d5eea Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Fri, 7 Jul 2023 22:43:07 -0400 Subject: [PATCH] Retry fetching Wi-Fi ssids (#391) --- src/install-dialog.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/install-dialog.ts b/src/install-dialog.ts index 21bac9f..11e19ab 100644 --- a/src/install-dialog.ts +++ b/src/install-dialog.ts @@ -736,7 +736,7 @@ export class EwtInstallDialog extends LitElement { } } - private async _updateSsids() { + private async _updateSsids(tries = 0) { const oldSsids = this._ssids; this._ssids = undefined; this._busy = true; @@ -746,7 +746,7 @@ export class EwtInstallDialog extends LitElement { try { ssids = await this._client!.scan(); } catch (err) { - // When we fail on first load, pick "Join other" + // When we fail while loading, pick "Join other" if (this._ssids === undefined) { this._ssids = null; this._selectedSsid = null; @@ -755,6 +755,13 @@ export class EwtInstallDialog extends LitElement { return; } + // We will retry a few times if we don't get any results + if (ssids.length === 0 && tries < 3) { + console.log("SCHEDULE RETRY", tries); + setTimeout(() => this._updateSsids(tries + 1), 1000); + return; + } + if (oldSsids) { // If we had a previous list, ensure the selection is still valid if (