Procházet zdrojové kódy

pass only needed options

Gildas před 7 roky
rodič
revize
88e4765373
2 změnil soubory, kde provedl 5 přidání a 5 odebrání
  1. 3 3
      extension/core/content/content.js
  2. 2 2
      extension/ui/bg/ui.js

+ 3 - 3
extension/core/content/content.js

@@ -54,7 +54,7 @@ this.singlefile.top = this.singlefile.top || (() => {
 						revokeDownloadURL(page);
 					} catch (error) {
 						console.error(error); // eslint-disable-line no-console
-						browser.runtime.sendMessage({ processError: true, error, options });
+						browser.runtime.sendMessage({ processError: true, error, options: { autoSave: options.autoSave } });
 					}
 					if (!options.autoSave) {
 						processing = false;
@@ -131,7 +131,7 @@ this.singlefile.top = this.singlefile.top || (() => {
 		options.onprogress = async event => {
 			if (event.type == event.RESOURCES_INITIALIZED || event.type == event.RESOURCE_LOADED) {
 				try {
-					await browser.runtime.sendMessage({ processProgress: true, index: event.details.index, maxIndex: event.details.max, options });
+					await browser.runtime.sendMessage({ processProgress: true, index: event.details.index, maxIndex: event.details.max, options: { autoSave: options.autoSave } });
 				} catch (error) {
 					/* ignored */
 				}
@@ -140,7 +140,7 @@ this.singlefile.top = this.singlefile.top || (() => {
 				}
 			} else if (event.type == event.PAGE_ENDED) {
 				try {
-					await browser.runtime.sendMessage({ processEnd: true, options });
+					await browser.runtime.sendMessage({ processEnd: true, options: { autoSave: options.autoSave } });
 				} catch (error) {
 					/* ignored */
 				}

+ 2 - 2
extension/ui/bg/ui.js

@@ -232,7 +232,7 @@ singlefile.ui = (() => {
 		}
 	}
 
-	async function processTab(tab, options) {
+	async function processTab(tab, options = {}) {
 		const tabId = tab.id;
 		try {
 			refreshBadge(tabId, {
@@ -256,7 +256,7 @@ singlefile.ui = (() => {
 			}, options);
 		} catch (error) {
 			if (error) {
-				onTabError(tabId);
+				onTabError(tabId, options);
 			} else {
 				refreshBadge(tabId, {
 					id: tabId,