Parcourir la source

refactored handling of bookmarId to support the editor

Former-commit-id: 785e28fe5a639c29d6cd40e0fb9f4437c5649d90
Gildas il y a 6 ans
Parent
commit
3c6a9c8ae0

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

@@ -171,9 +171,6 @@ singlefile.extension.core.bg.business = (() => {
 				taskInfo.options.taskId = taskId;
 				tabs.sendMessage(taskInfo.tab.id, { method: taskInfo.method, options: taskInfo.options })
 					.then(() => {
-						if (taskInfo.options.replaceBookmarkURL && taskInfo.options.bookmarkId && taskInfo.options.filename) {
-							singlefile.extension.core.bg.bookmarks.update(taskInfo.options.bookmarkId, { url: taskInfo.options.filename });
-						}
 						if (taskInfo.options.autoClose && !taskInfo.cancelled) {
 							tabs.remove(taskInfo.tab.id);
 						}

+ 5 - 6
extension/core/bg/downloads.js

@@ -109,7 +109,9 @@ singlefile.extension.core.bg.downloads = (() => {
 					incognito: tab.incognito,
 					filenameConflictAction: message.filenameConflictAction,
 					filenameReplacementCharacter: message.filenameReplacementCharacter,
-					compressHTML: message.compressHTML
+					compressHTML: message.compressHTML,
+					bookmarkId: message.bookmarkId,
+					replaceBookmarkURL: message.replaceBookmarkURL
 				});
 			} else {
 				if (message.saveToClipboard) {
@@ -223,11 +225,8 @@ singlefile.extension.core.bg.downloads = (() => {
 			downloadInfo.incognito = true;
 		}
 		const downloadData = await download(downloadInfo, options.filenameReplacementCharacter);
-		if (downloadData.filename) {
-			const taskInfo = singlefile.extension.core.bg.business.getTaskInfo(pageData.taskId);
-			if (taskInfo) {
-				taskInfo.options.filename = "file:///" + encodeURI(downloadData.filename.replace(/\\/gi, "/"));
-			}
+		if (downloadData.filename && pageData.bookmarkId && pageData.replaceBookmarkURL) {
+			await singlefile.extension.core.bg.bookmarks.update(pageData.bookmarkId, { url: downloadData.filename });
 		}
 	}
 

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

@@ -50,7 +50,9 @@ this.singlefile.extension.core.content.download = this.singlefile.extension.core
 					filenameReplacementCharacter: options.filenameReplacementCharacter,
 					openEditor: options.openEditor,
 					compressHTML: options.compressHTML,
-					backgroundSave: options.backgroundSave
+					backgroundSave: options.backgroundSave,
+					bookmarkId: options.bookmarkId,
+					replaceBookmarkURL: options.replaceBookmarkURL
 				};
 				message.truncated = pageData.content.length > MAX_CONTENT_SIZE;
 				if (message.truncated) {