From 84a57aad021ce0bfd4c9acdeb68e47a444546a61 Mon Sep 17 00:00:00 2001 From: Zixuan Chen Date: Thu, 1 Oct 2020 11:48:57 +0800 Subject: [PATCH] fix: bk correctly & remove compact method --- src/main/init.ts | 4 +--- src/main/io/write.ts | 10 +++++++--- src/renderer/dbs.ts | 4 +--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/init.ts b/src/main/init.ts index 42f5aee..b116d53 100644 --- a/src/main/init.ts +++ b/src/main/init.ts @@ -10,7 +10,7 @@ import { AutoUpdater } from './AutoUpdater'; import { initialize } from './ipc/ipc'; import { IpcEventName } from './ipc/type'; -const { compact, refreshDbs, loadDBs } = db; +const { refreshDbs, loadDBs } = db; export let win: BrowserWindow | undefined; export const gotTheLock = process.env.NODE_ENV !== 'production' || app.requestSingleInstanceLock(); @@ -30,7 +30,6 @@ if (!gotTheLock) { const mGlobal: typeof global & { sharedDB?: typeof db.DBs; utils?: { - compact: typeof compact; refreshDbs: typeof refreshDbs; loadDBs: typeof loadDBs; }; @@ -40,7 +39,6 @@ const mGlobal: typeof global & { } = global; mGlobal.sharedDB = db.DBs; mGlobal.utils = { - compact, refreshDbs, loadDBs, }; diff --git a/src/main/io/write.ts b/src/main/io/write.ts index 7071361..9ea8171 100644 --- a/src/main/io/write.ts +++ b/src/main/io/write.ts @@ -67,7 +67,11 @@ export async function generateBackup() { } const backup = await readAllData(); - await promisify(writeFile)(path.join(dbBkBaseDir, 'pomodoro-logger-data-backup.json'), backup, { - encoding: 'utf-8', - }); + await promisify(writeFile)( + path.join(dbBkBaseDir, 'pomodoro-logger-data-backup.json'), + JSON.stringify(backup), + { + encoding: 'utf-8', + } + ); } diff --git a/src/renderer/dbs.ts b/src/renderer/dbs.ts index cc35950..4b34e09 100644 --- a/src/renderer/dbs.ts +++ b/src/renderer/dbs.ts @@ -1,16 +1,14 @@ /* istanbul ignore file */ import { remote } from 'electron'; -import { DBs, refreshDbs as _refresh, compact as _compact, loadDBs as _loadDBs } from '../main/db'; +import { DBs, refreshDbs as _refresh, loadDBs as _loadDBs } from '../main/db'; export let refreshDbs = _refresh; -export let compact = _compact; export let loadDBs = _loadDBs; export let dbs: typeof DBs; if (remote) { dbs = remote.getGlobal('sharedDB'); const utils = remote.getGlobal('utils'); refreshDbs = utils.refreshDbs; - compact = utils.compact; loadDBs = utils.loadDBs; }