Skip to content
This repository has been archived by the owner on Apr 14, 2023. It is now read-only.

Commit

Permalink
fix: bk correctly & remove compact method
Browse files Browse the repository at this point in the history
  • Loading branch information
zxch3n committed Oct 1, 2020
1 parent 279834d commit 84a57aa
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 1 addition & 3 deletions src/main/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -30,7 +30,6 @@ if (!gotTheLock) {
const mGlobal: typeof global & {
sharedDB?: typeof db.DBs;
utils?: {
compact: typeof compact;
refreshDbs: typeof refreshDbs;
loadDBs: typeof loadDBs;
};
Expand All @@ -40,7 +39,6 @@ const mGlobal: typeof global & {
} = global;
mGlobal.sharedDB = db.DBs;
mGlobal.utils = {
compact,
refreshDbs,
loadDBs,
};
Expand Down
10 changes: 7 additions & 3 deletions src/main/io/write.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}
);
}
4 changes: 1 addition & 3 deletions src/renderer/dbs.ts
Original file line number Diff line number Diff line change
@@ -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;
}

Expand Down

0 comments on commit 84a57aa

Please sign in to comment.