Changed db import to use importInto

This commit is contained in:
Mitchell McCaffrey 2021-02-11 23:01:32 +11:00
parent 8117f7da2e
commit 57e64e132b
2 changed files with 3 additions and 3 deletions

@ -35,7 +35,6 @@ function ImportDatabaseModal({ isOpen, onRequestClose }) {
async function handleImportDatabase(file) {
setIsLoading(true);
backgroundTaskRunningRef.current = true;
await database.delete();
await worker.importData(file, Comlink.proxy(handleDBProgress));
setIsLoading(false);
backgroundTaskRunningRef.current = false;

@ -1,5 +1,5 @@
import * as Comlink from "comlink";
import { importDB, exportDB } from "dexie-export-import";
import { importInto, exportDB } from "dexie-export-import";
import { encode } from "@msgpack/msgpack";
import { getDatabase } from "../database";
@ -59,7 +59,8 @@ let service = {
*/
async importData(data, progressCallback) {
try {
await importDB(data, { progressCallback });
let db = getDatabase({});
await importInto(db, data, { progressCallback, overwriteValues: true });
} catch {}
},
};