Promise eslint errors fixed

This commit is contained in:
baku 2017-01-17 10:47:19 +01:00
parent e44cc95d7f
commit d49120cc62
2 changed files with 28 additions and 10 deletions

View file

@ -103,6 +103,8 @@ const ContainerService = {
sendReply(this[message.method](message));
}
});
}).catch(() => {
throw new Error("WebExtension startup failed. Unable to continue.");
});
},
@ -194,8 +196,7 @@ const ContainerService = {
showTabs(args) {
if (!("userContextId" in args)) {
Promise.reject("showTabs must be called with userContextId argument.");
return;
return Promise.reject("showTabs must be called with userContextId argument.");
}
const promises = [];
@ -279,6 +280,8 @@ const ContainerService = {
Promise.all(promises).then(() => {
resolve(list);
}).catch((e) => {
reject(e);
});
});
},
@ -386,8 +389,7 @@ const ContainerService = {
getIdentity(args) {
if (!("userContextId" in args)) {
Promise.reject("getIdentity must be called with userContextId argument.");
return;
return Promise.reject("getIdentity must be called with userContextId argument.");
}
const identity = ContextualIdentityService.getIdentityFromId(args.userContextId);
@ -397,8 +399,7 @@ const ContainerService = {
createIdentity(args) {
for (let arg of [ "name", "color", "icon"]) { // eslint-disable-line prefer-const
if (!(arg in args)) {
Promise.reject("createIdentity must be called with " + arg + " argument.");
return;
return Promise.reject("createIdentity must be called with " + arg + " argument.");
}
}
@ -415,8 +416,7 @@ const ContainerService = {
updateIdentity(args) {
if (!("userContextId" in args)) {
Promise.reject("updateIdentity must be called with userContextId argument.");
return;
return Promise.reject("updateIdentity must be called with userContextId argument.");
}
const identity = ContextualIdentityService.getIdentityFromId(args.userContextId);
@ -436,8 +436,7 @@ const ContainerService = {
removeIdentity(args) {
if (!("userContextId" in args)) {
Promise.reject("removeIdentity must be called with userContextId argument.");
return;
return Promise.reject("removeIdentity must be called with userContextId argument.");
}
return Promise.resolve(ContextualIdentityService.remove(args.userContextId));
},

View file

@ -44,6 +44,10 @@ const Logic = {
} else {
this.showPanel(P_ONBOARDING_1);
}
})
.catch(() => {
throw new Error("Failed to retrieve the identities. We cannot continue.");
});
},
@ -73,6 +77,9 @@ const Logic = {
panelElement.classList.add("hide");
}
document.querySelector(this._panels[panel].panelSelector).classList.remove("hide");
})
.catch(() => {
throw new Error("Failed to show panel " + panel);
});
},
@ -186,6 +193,8 @@ Logic.registerPanel(P_CONTAINERS_LIST, {
method: "sortTabs"
}).then(() => {
window.close();
}).catch(() => {
window.close();
});
});
},
@ -221,6 +230,8 @@ Logic.registerPanel(P_CONTAINERS_LIST, {
});
}).then(() => {
window.close();
}).catch(() => {
window.close();
});
} else if (e.target.matches(".info")) {
Logic.showPanel(P_CONTAINER_INFO, identity);
@ -256,6 +267,8 @@ Logic.registerPanel(P_CONTAINER_INFO, {
userContextId: identity.userContextId
}).then(() => {
window.close();
}).catch(() => {
window.close();
});
});
@ -318,6 +331,8 @@ Logic.registerPanel(P_CONTAINER_INFO, {
tabId: tab.id,
}).then(() => {
window.close();
}).catch(() => {
window.close();
});
});
}
@ -418,6 +433,8 @@ Logic.registerPanel(P_CONTAINER_EDIT, {
return Logic.refreshIdentities();
}).then(() => {
Logic.showPreviousPanel();
}).catch(() => {
Logic.showPanel(P_CONTAINERS_LIST);
});
});
},
@ -453,6 +470,8 @@ Logic.registerPanel(P_CONTAINER_DELETE, {
return Logic.refreshIdentities();
}).then(() => {
Logic.showPreviousPanel();
}).catch(() => {
Logic.showPanel(P_CONTAINERS_LIST);
});
});
},