浏览代码

autoclose the tab after the page is saved (see #546)

Gildas 5 年之前
父节点
当前提交
24c12cff78
共有 2 个文件被更改,包括 3 次插入6 次删除
  1. 0 3
      extension/core/bg/autosave.js
  2. 3 3
      extension/core/bg/business.js

+ 0 - 3
extension/core/bg/autosave.js

@@ -43,9 +43,6 @@ singlefile.extension.core.bg.autosave = (() => {
 			const tabId = sender.tab.id;
 			const options = await singlefile.extension.core.bg.config.getOptions(sender.tab.url, true);
 			if (options) {
-				if (options.autoClose) {
-					singlefile.extension.core.bg.tabs.remove(tabId);
-				}
 				ui.onStart(tabId, 1, true);
 				await saveContent(message, sender.tab);
 				ui.onEnd(tabId, true);

+ 3 - 3
extension/core/bg/business.js

@@ -68,6 +68,9 @@ singlefile.extension.core.bg.business = (() => {
 		onSaveEnd: taskId => {
 			const taskInfo = tasks.find(taskInfo => taskInfo.id == taskId);
 			if (taskInfo) {
+				if (taskInfo.options.autoClose && !taskInfo.cancelled) {
+					singlefile.extension.core.bg.tabs.remove(taskInfo.tab.id);
+				}
 				taskInfo.done();
 			}
 		},
@@ -210,9 +213,6 @@ singlefile.extension.core.bg.business = (() => {
 		taskInfo.options.taskId = taskId;
 		try {
 			await tabs.sendMessage(taskInfo.tab.id, { method: taskInfo.method, options: taskInfo.options });
-			if (taskInfo.options.autoClose && !taskInfo.cancelled) {
-				tabs.remove(taskInfo.tab.id);
-			}
 		} catch (error) {
 			if (error && (!error.message || !isIgnoredError(error))) {
 				console.log(error.message ? error.message : error); // eslint-disable-line no-console