Sfoglia il codice sorgente

don't serialize host objects

Former-commit-id: e9b8351dd1dd9fff3f8e4892fa7f32fc407887ea
Gildas 6 anni fa
parent
commit
6cca0aa24c
2 ha cambiato i file con 9 aggiunte e 5 eliminazioni
  1. 5 1
      extension/core/bg/business.js
  2. 4 4
      extension/ui/bg/ui-pendings.js

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

@@ -51,7 +51,7 @@ singlefile.extension.core.bg.business = (() => {
 		saveTabs,
 		saveLink,
 		cancelTab,
-		getInfo: () => ({ pending: Array.from(pendingSaves), processing: Array.from(currentSaves) })
+		getInfo: () => ({ pending: Array.from(pendingSaves).map(mapSaveInfo), processing: Array.from(currentSaves).map(mapSaveInfo) })
 	};
 
 	async function saveTabs(tabs, options = {}) {
@@ -149,4 +149,8 @@ singlefile.extension.core.bg.business = (() => {
 		}
 	}
 
+	function mapSaveInfo([tabId, saveInfo]) {
+		return [tabId, { index: saveInfo.tab.index, url: saveInfo.tab.url, cancelled: saveInfo.cancelled }];
+	}
+
 })();

+ 4 - 4
extension/ui/bg/ui-pendings.js

@@ -55,8 +55,8 @@
 	function updateTable(results, type) {
 		const data = results[type];
 		if (data.length) {
-			data.sort(([, saveInfo1], [, saveInfo2]) => saveInfo1.tab.index - saveInfo2.tab.index);
-			data.forEach(([tabId, saveInfo]) => {
+			data.sort(([, tabInfo1], [, tabInfo2]) => tabInfo1.index - tabInfo2.index);
+			data.forEach(([tabId, tabInfo]) => {
 				const row = document.createElement("div");
 				const cellURL = document.createElement("span");
 				const cellStatus = document.createElement("span");
@@ -64,10 +64,10 @@
 				const buttonCancel = document.createElement("button");
 				row.dataset.tabId = tabId;
 				row.className = "result-row result-type-" + type;
-				cellURL.textContent = saveInfo.tab.url;
+				cellURL.textContent = tabInfo.url;
 				cellURL.className = "result-url";
 				cellURL.onclick = () => selectTab(type, tabId);
-				if (saveInfo.cancelled) {
+				if (tabInfo.cancelled) {
 					cellStatus.textContent = statusText.cancelling;
 				} else {
 					cellStatus.textContent = statusText[type];