Explorar o código

added isSavingTab and cancelTab methods

Former-commit-id: f4016e7573a5f8339e3c902676f0ce9cebe3d44c
Gildas %!s(int64=6) %!d(string=hai) anos
pai
achega
873414189d
Modificáronse 1 ficheiros con 13 adicións e 1 borrados
  1. 13 1
      extension/core/bg/business.js

+ 13 - 1
extension/core/bg/business.js

@@ -78,7 +78,11 @@ singlefile.extension.core.bg.business = (() => {
 	const currentSaves = new Map();
 	let maxParallelWorkers;
 
-	return { saveTab };
+	return {
+		isSavingTab: tab => currentSaves.has(tab.id),
+		saveTab,
+		cancelTab
+	};
 
 	async function saveTab(tab, options = {}) {
 		const config = singlefile.extension.core.bg.config;
@@ -133,6 +137,14 @@ singlefile.extension.core.bg.business = (() => {
 		}
 	}
 
+	async function cancelTab(tab) {
+		try {
+			singlefile.extension.core.bg.tabs.sendMessage(tab.id, { method: "content.cancelSave" });
+		} catch (error) {
+			// ignored;
+		}
+	}
+
 	function requestSaveTab(tabId, method, options) {
 		return new Promise((resolve, reject) => requestSaveTab(tabId, method, options, resolve, reject));