replace a .then() with await Promise.all()

This commit is contained in:
groovecoder 2017-06-15 11:23:39 -05:00 committed by Jonathan Kingston
parent 5237e67fa6
commit 4ed136299b

View file

@ -72,7 +72,7 @@ const Logic = {
_panels: {}, _panels: {},
_onboardingVariation: null, _onboardingVariation: null,
init() { async init() {
// Remove browserAction "upgraded" badge when opening panel // Remove browserAction "upgraded" badge when opening panel
this.clearBrowserActionBadge(); this.clearBrowserActionBadge();
@ -81,26 +81,26 @@ const Logic = {
// Get the onboarding variation // Get the onboarding variation
const variationPromise = this.getShieldStudyVariation(); const variationPromise = this.getShieldStudyVariation();
// Routing to the correct panel. try {
Promise.all([identitiesPromise, variationPromise]) await Promise.all([identitiesPromise, variationPromise]);
.then(() => { } catch(e) {
// If localStorage is disabled, we don't show the onboarding. throw new Error("Failed to retrieve the identities or variation. We cannot continue. ", e.message);
if (!localStorage || localStorage.getItem("onboarded4")) { }
this.showPanel(P_CONTAINERS_LIST);
} else if (localStorage.getItem("onboarded3")) { // Routing to the correct panel.
this.showPanel(P_ONBOARDING_4); // If localStorage is disabled, we don't show the onboarding.
} else if (localStorage.getItem("onboarded2")) { if (!localStorage || localStorage.getItem("onboarded4")) {
this.showPanel(P_ONBOARDING_3); this.showPanel(P_CONTAINERS_LIST);
} else if (localStorage.getItem("onboarded1")) { } else if (localStorage.getItem("onboarded3")) {
this.showPanel(P_ONBOARDING_2); this.showPanel(P_ONBOARDING_4);
} else { } else if (localStorage.getItem("onboarded2")) {
this.showPanel(P_ONBOARDING_1); this.showPanel(P_ONBOARDING_3);
} } else if (localStorage.getItem("onboarded1")) {
}) this.showPanel(P_ONBOARDING_2);
} else {
this.showPanel(P_ONBOARDING_1);
}
.catch(() => {
throw new Error("Failed to retrieve the identities. We cannot continue.");
});
}, },
async clearBrowserActionBadge() { async clearBrowserActionBadge() {