Gildas 4 лет назад
Родитель
Сommit
c2188cf74f
2 измененных файлов с 12 добавлено и 4 удалено
  1. 6 2
      extension/core/bg/autosave.js
  2. 6 2
      extension/core/bg/tabs.js

+ 6 - 2
extension/core/bg/autosave.js

@@ -156,8 +156,12 @@ async function saveContent(message, tab) {
 					await downloads.downloadPage(pageData, options);
 					if (options.openSavedPage) {
 						const createTabProperties = { active: true, url: URL.createObjectURL(blob) };
-						if (tab.index != null) {
-							createTabProperties.index = tab.index + (pendingDiscardedTabs[tabId] ? 1 : 0);
+						const index = tab.index;
+						try {
+							await tabs.get({ id: tabId });
+							createTabProperties.index = index + 1;
+						} catch (error) {
+							createTabProperties.index = index;
 						}
 						tabs.create(createTabProperties);
 					}

+ 6 - 2
extension/core/bg/tabs.js

@@ -110,8 +110,12 @@ async function createAndWait(createProperties) {
 }
 
 async function get(options) {
-	const tabs = await browser.tabs.query(options);
-	return tabs.sort((tab1, tab2) => tab1.index - tab2.index);
+	if (options.id) {
+		return browser.tabs.get(options.id);
+	} else {
+		const tabs = await browser.tabs.query(options);
+		return tabs.sort((tab1, tab2) => tab1.index - tab2.index);
+	}
 }
 
 async function promptValue(promptMessage) {