Changed db import to use importInto
This commit is contained in:
parent
8117f7da2e
commit
57e64e132b
@ -35,7 +35,6 @@ function ImportDatabaseModal({ isOpen, onRequestClose }) {
|
|||||||
async function handleImportDatabase(file) {
|
async function handleImportDatabase(file) {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
backgroundTaskRunningRef.current = true;
|
backgroundTaskRunningRef.current = true;
|
||||||
await database.delete();
|
|
||||||
await worker.importData(file, Comlink.proxy(handleDBProgress));
|
await worker.importData(file, Comlink.proxy(handleDBProgress));
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
backgroundTaskRunningRef.current = false;
|
backgroundTaskRunningRef.current = false;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import * as Comlink from "comlink";
|
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 { encode } from "@msgpack/msgpack";
|
||||||
|
|
||||||
import { getDatabase } from "../database";
|
import { getDatabase } from "../database";
|
||||||
@ -59,7 +59,8 @@ let service = {
|
|||||||
*/
|
*/
|
||||||
async importData(data, progressCallback) {
|
async importData(data, progressCallback) {
|
||||||
try {
|
try {
|
||||||
await importDB(data, { progressCallback });
|
let db = getDatabase({});
|
||||||
|
await importInto(db, data, { progressCallback, overwriteValues: true });
|
||||||
} catch {}
|
} catch {}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user