Recording - minor fix to popup.js ('0' is a valid tabId), plus whitespace fixes
This commit is contained in:
parent
30a2601d35
commit
46fe530f62
4 changed files with 40 additions and 36 deletions
|
@ -80,7 +80,6 @@ const messageHandler = {
|
|||
response = backgroundLogic.asPromise(backgroundLogic.invokeBrowserMethod(m.name, m.args));
|
||||
break;
|
||||
}
|
||||
|
||||
return response;
|
||||
});
|
||||
|
||||
|
@ -264,32 +263,36 @@ const messageHandler = {
|
|||
} while (!succeeded);
|
||||
}
|
||||
|
||||
handleTabChangedStatus(status) {
|
||||
if (status === "loading") {
|
||||
handleTabStatusLoading() {
|
||||
if (!this.tabLoading) {
|
||||
this.tabLoading = {};
|
||||
this.tabLoading.promise = new Promise((resolve) => {
|
||||
this.tabLoading.resolve = resolve;
|
||||
});
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
handleTabStatusComplete() {
|
||||
if (this.tabLoading) {
|
||||
this.tabLoading.resolve();
|
||||
this.tabLoading = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
handleTabRemoved() {
|
||||
this.tabRemoved = true;
|
||||
this.removeTabListeners();
|
||||
this.handleTabChangedStatus("complete");
|
||||
this.handleTabStatusComplete();
|
||||
}
|
||||
|
||||
addTabListeners() {
|
||||
this.onTabsUpdated = (eventTabId, info) => {
|
||||
if (this.tabId === eventTabId) {
|
||||
this.handleTabChangedStatus(info.status);
|
||||
if (info.status === "loading") {
|
||||
this.handleTabStatusLoading();
|
||||
} else {
|
||||
this.handleTabStatusComplete();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ const Env = {
|
|||
this.tabId = parseInt(tabId, 10);
|
||||
this.isBrowserActionPopup = false;
|
||||
} else {
|
||||
this.tabId = null;
|
||||
this.tabId = -1;
|
||||
this.isBrowserActionPopup = this.hasFullBrowserAPI;
|
||||
}
|
||||
}
|
||||
|
@ -109,6 +109,7 @@ const Logic = {
|
|||
|
||||
// Retrieve the list of identities.
|
||||
const identitiesPromise = this.refreshIdentities();
|
||||
|
||||
try {
|
||||
await identitiesPromise;
|
||||
} catch (e) {
|
||||
|
@ -257,7 +258,7 @@ const Logic = {
|
|||
},
|
||||
|
||||
async currentTab() {
|
||||
if (Env.tabId) {
|
||||
if (Env.tabId >= 0) {
|
||||
return await browser.tabs.get(Env.tabId);
|
||||
} else {
|
||||
const activeTabs = await browser.tabs.query({ active: true, windowId: browser.windows.WINDOW_ID_CURRENT });
|
||||
|
|
Loading…
Add table
Reference in a new issue