Refactor async anonymous functions into arrow functions

- fixes #972
This commit is contained in:
ctgardner 2019-04-15 18:38:10 +10:00 committed by Jonathan Kingston
parent 2ded900188
commit 639399925c
2 changed files with 15 additions and 15 deletions

View file

@ -218,7 +218,7 @@ const backgroundLogic = {
async queryIdentitiesState(windowId) { async queryIdentitiesState(windowId) {
const identities = await browser.contextualIdentities.query({}); const identities = await browser.contextualIdentities.query({});
const identitiesOutput = {}; const identitiesOutput = {};
const identitiesPromise = identities.map(async function (identity) { const identitiesPromise = identities.map(async (identity) => {
const { cookieStoreId } = identity; const { cookieStoreId } = identity;
const containerState = await identityState.storageArea.get(cookieStoreId); const containerState = await identityState.storageArea.get(cookieStoreId);
const openTabs = await browser.tabs.query({ const openTabs = await browser.tabs.query({

View file

@ -395,7 +395,7 @@ Logic.registerPanel(P_ONBOARDING_1, {
initialize() { initialize() {
// Let's move to the next panel. // Let's move to the next panel.
[...document.querySelectorAll(".onboarding-start-button")].forEach(startElement => { [...document.querySelectorAll(".onboarding-start-button")].forEach(startElement => {
Logic.addEnterHandler(startElement, async function () { Logic.addEnterHandler(startElement, async () => {
await Logic.setOnboardingStage(1); await Logic.setOnboardingStage(1);
Logic.showPanel(P_ONBOARDING_2); Logic.showPanel(P_ONBOARDING_2);
}); });
@ -419,7 +419,7 @@ Logic.registerPanel(P_ONBOARDING_2, {
initialize() { initialize() {
// Let's move to the containers list panel. // Let's move to the containers list panel.
[...document.querySelectorAll(".onboarding-next-button")].forEach(nextElement => { [...document.querySelectorAll(".onboarding-next-button")].forEach(nextElement => {
Logic.addEnterHandler(nextElement, async function () { Logic.addEnterHandler(nextElement, async () => {
await Logic.setOnboardingStage(2); await Logic.setOnboardingStage(2);
Logic.showPanel(P_ONBOARDING_3); Logic.showPanel(P_ONBOARDING_3);
}); });
@ -443,7 +443,7 @@ Logic.registerPanel(P_ONBOARDING_3, {
initialize() { initialize() {
// Let's move to the containers list panel. // Let's move to the containers list panel.
[...document.querySelectorAll(".onboarding-almost-done-button")].forEach(almostElement => { [...document.querySelectorAll(".onboarding-almost-done-button")].forEach(almostElement => {
Logic.addEnterHandler(almostElement, async function () { Logic.addEnterHandler(almostElement, async () => {
await Logic.setOnboardingStage(3); await Logic.setOnboardingStage(3);
Logic.showPanel(P_ONBOARDING_4); Logic.showPanel(P_ONBOARDING_4);
}); });
@ -465,7 +465,7 @@ Logic.registerPanel(P_ONBOARDING_4, {
// This method is called when the object is registered. // This method is called when the object is registered.
initialize() { initialize() {
// Let's move to the containers list panel. // Let's move to the containers list panel.
Logic.addEnterHandler(document.querySelector("#onboarding-done-button"), async function () { Logic.addEnterHandler(document.querySelector("#onboarding-done-button"), async () => {
await Logic.setOnboardingStage(4); await Logic.setOnboardingStage(4);
Logic.showPanel(P_ONBOARDING_5); Logic.showPanel(P_ONBOARDING_5);
}); });
@ -486,7 +486,7 @@ Logic.registerPanel(P_ONBOARDING_5, {
// This method is called when the object is registered. // This method is called when the object is registered.
initialize() { initialize() {
// Let's move to the containers list panel. // Let's move to the containers list panel.
Logic.addEnterHandler(document.querySelector("#onboarding-longpress-button"), async function () { Logic.addEnterHandler(document.querySelector("#onboarding-longpress-button"), async () => {
await Logic.setOnboardingStage(5); await Logic.setOnboardingStage(5);
Logic.showPanel(P_CONTAINERS_LIST); Logic.showPanel(P_CONTAINERS_LIST);
}); });
@ -516,7 +516,7 @@ Logic.registerPanel(P_CONTAINERS_LIST, {
} }
}); });
Logic.addEnterHandler(document.querySelector("#sort-containers-link"), async function () { Logic.addEnterHandler(document.querySelector("#sort-containers-link"), async () => {
try { try {
await browser.runtime.sendMessage({ await browser.runtime.sendMessage({
method: "sortTabs" method: "sortTabs"
@ -659,7 +659,7 @@ Logic.registerPanel(P_CONTAINERS_LIST, {
tr.appendChild(manage); tr.appendChild(manage);
} }
Logic.addEnterHandler(tr, async function (e) { Logic.addEnterHandler(tr, async (e) => {
if (e.target.matches(".open-newtab") if (e.target.matches(".open-newtab")
|| e.target.parentNode.matches(".open-newtab") || e.target.parentNode.matches(".open-newtab")
|| e.type === "keydown") { || e.type === "keydown") {
@ -717,7 +717,7 @@ Logic.registerPanel(P_CONTAINER_INFO, {
Logic.showPreviousPanel(); Logic.showPreviousPanel();
}); });
Logic.addEnterHandler(document.querySelector("#container-info-hideorshow"), async function () { Logic.addEnterHandler(document.querySelector("#container-info-hideorshow"), async () => {
const identity = Logic.currentIdentity(); const identity = Logic.currentIdentity();
try { try {
browser.runtime.sendMessage({ browser.runtime.sendMessage({
@ -749,7 +749,7 @@ Logic.registerPanel(P_CONTAINER_INFO, {
Logic._disableMoveTabs("Cannot move a tab from a single-tab window."); Logic._disableMoveTabs("Cannot move a tab from a single-tab window.");
return; return;
} }
Logic.addEnterHandler(moveTabsEl, async function () { Logic.addEnterHandler(moveTabsEl, async () => {
await browser.runtime.sendMessage({ await browser.runtime.sendMessage({
method: "moveTabsToWindow", method: "moveTabsToWindow",
windowId: browser.windows.WINDOW_ID_CURRENT, windowId: browser.windows.WINDOW_ID_CURRENT,
@ -829,14 +829,14 @@ Logic.registerPanel(P_CONTAINER_INFO, {
tr.addEventListener("mouseout", tabTitleHoverEvent); tr.addEventListener("mouseout", tabTitleHoverEvent);
tr.classList.add("clickable"); tr.classList.add("clickable");
Logic.addEnterHandler(tr, async function () { Logic.addEnterHandler(tr, async () => {
await browser.tabs.update(tab.id, {active: true}); await browser.tabs.update(tab.id, {active: true});
window.close(); window.close();
}); });
const closeTab = document.getElementById(tab.id); const closeTab = document.getElementById(tab.id);
if (closeTab) { if (closeTab) {
Logic.addEnterHandler(closeTab, async function(e) { Logic.addEnterHandler(closeTab, async (e) => {
await browser.tabs.remove(Number(e.target.id)); await browser.tabs.remove(Number(e.target.id));
window.close(); window.close();
}); });
@ -997,7 +997,7 @@ Logic.registerPanel(P_CONTAINER_EDIT, {
/>`; />`;
const deleteButton = trElement.querySelector(".delete-assignment"); const deleteButton = trElement.querySelector(".delete-assignment");
const that = this; const that = this;
Logic.addEnterHandler(deleteButton, async function () { Logic.addEnterHandler(deleteButton, async () => {
const userContextId = Logic.currentUserContextId(); const userContextId = Logic.currentUserContextId();
// Lets show the message to the current tab // Lets show the message to the current tab
// TODO remove then when firefox supports arrow fn async // TODO remove then when firefox supports arrow fn async
@ -1082,7 +1082,7 @@ Logic.registerPanel(P_CONTAINER_DELETE, {
Logic.showPreviousPanel(); Logic.showPreviousPanel();
}); });
Logic.addEnterHandler(document.querySelector("#delete-container-ok-link"), async function () { Logic.addEnterHandler(document.querySelector("#delete-container-ok-link"), async () => {
/* This promise wont resolve if the last tab was removed from the window. /* This promise wont resolve if the last tab was removed from the window.
as the message async callback stops listening, this isn't an issue for us however it might be in future as the message async callback stops listening, this isn't an issue for us however it might be in future
if you want to do anything post delete do it in the background script. if you want to do anything post delete do it in the background script.
@ -1130,7 +1130,7 @@ Logic.registerPanel(P_CONTAINERS_ACHIEVEMENT, {
// This method is called when the object is registered. // This method is called when the object is registered.
initialize() { initialize() {
// Set done and move to the containers list panel. // Set done and move to the containers list panel.
Logic.addEnterHandler(document.querySelector("#achievement-done-button"), async function () { Logic.addEnterHandler(document.querySelector("#achievement-done-button"), async () => {
await Logic.setAchievementDone("manyContainersOpened"); await Logic.setAchievementDone("manyContainersOpened");
Logic.showPanel(P_CONTAINERS_LIST); Logic.showPanel(P_CONTAINERS_LIST);
}); });