Added comlink.transfer to export

This commit is contained in:
Mitchell McCaffrey 2021-04-15 15:18:47 +10:00
parent 9cf2b35f1e
commit 7acb6bb161
2 changed files with 7 additions and 2 deletions

View File

@ -206,11 +206,12 @@ function ImportExportModal({ isOpen, onRequestClose }) {
const tokenIds = checkedTokens.map((token) => token.id);
try {
const blob = await worker.exportData(
const buffer = await worker.exportData(
Comlink.proxy(handleDBProgress),
mapIds,
tokenIds
);
const blob = new Blob([buffer]);
saveAs(blob, `${shortid.generate()}.owlbear`);
addSuccessToast("Exported", checkedMaps, checkedTokens);
} catch (e) {

View File

@ -7,6 +7,7 @@ import {
import { encode, decode } from "@msgpack/msgpack";
import { getDatabase } from "../database";
import blobToBuffer from "../helpers/blobToBuffer";
// Worker to load large amounts of database data on a separate thread
let service = {
@ -92,7 +93,10 @@ let service = {
numRowsPerChunk: 1,
prettyJson: true,
});
return data;
const buffer = await blobToBuffer(data);
return Comlink.transfer(buffer, [buffer.buffer]);
},
/**