From f441ee542a1f9e884639f071703df3dee5a24b9a Mon Sep 17 00:00:00 2001 From: Marcin S Date: Mon, 14 Feb 2022 09:19:56 -0600 Subject: [PATCH] Add explanatory comments --- scripts/ui.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/ui.ts b/scripts/ui.ts index 97fa1250..8d5bb79f 100644 --- a/scripts/ui.ts +++ b/scripts/ui.ts @@ -485,9 +485,16 @@ async function resolveOnMySkyPortalLogin(): Promise { // when the login attempt returns an error. const promise1 = new Promise((resolve, reject) => { const handleEvent = async ({ key, newValue }: StorageEvent) => { + // We only want the promise to resolve or reject when the right storage + // key is encountered. Any other storage key shouldn't trigger a `resolve`. if (key !== PORTAL_LOGIN_COMPLETE_SENTINEL_KEY) { return; } + // We only want the promise to resolve or reject when the right storage + // key is set, and not removed. + // + // NOTE: We do remove the storage key before setting it in Main MySky, + // because otherwise, setting an already-set key has no effect. if (!newValue) { // Key was removed. return;