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 bbc3054d21
commit 8cbb7f4545

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,9 +81,13 @@ const Logic = {
// Get the onboarding variation // Get the onboarding variation
const variationPromise = this.getShieldStudyVariation(); const variationPromise = this.getShieldStudyVariation();
try {
await Promise.all([identitiesPromise, variationPromise]);
} catch(e) {
throw new Error("Failed to retrieve the identities or variation. We cannot continue. ", e.message);
}
// Routing to the correct panel. // Routing to the correct panel.
Promise.all([identitiesPromise, variationPromise])
.then(() => {
// If localStorage is disabled, we don't show the onboarding. // If localStorage is disabled, we don't show the onboarding.
if (!localStorage || localStorage.getItem("onboarded4")) { if (!localStorage || localStorage.getItem("onboarded4")) {
this.showPanel(P_CONTAINERS_LIST); this.showPanel(P_CONTAINERS_LIST);
@ -96,11 +100,7 @@ const Logic = {
} else { } else {
this.showPanel(P_ONBOARDING_1); this.showPanel(P_ONBOARDING_1);
} }
})
.catch(() => {
throw new Error("Failed to retrieve the identities. We cannot continue.");
});
}, },
async clearBrowserActionBadge() { async clearBrowserActionBadge() {