1
0
mirror of https://github.com/bitwarden/desktop synced 2025-12-21 02:33:15 +00:00

automatic sync intervals

This commit is contained in:
Kyle Spearrin
2018-02-09 15:49:00 -05:00
parent ac647f3184
commit 3b3750734b
3 changed files with 47 additions and 3 deletions

View File

@@ -1,10 +1,19 @@
import { app, ipcMain } from 'electron';
// import { getPassword, setPassword, deletePassword } from 'keytar';
import { WindowMain } from './window.main';
const KeytarService = 'bitwarden';
const SyncInterval = 5 * 60 * 1000; // 5 minutes
export class MessagingMain {
private syncTimeout: NodeJS.Timer;
constructor(private windowMain: WindowMain) { }
init() {
this.scheduleNextSync();
ipcMain.on('messagingService', async (event: any, message: any) => {
switch (message.command) {
case 'loggedIn':
@@ -13,6 +22,9 @@ export class MessagingMain {
break;
case 'syncCompleted':
break;
case 'scheduleNextSync':
this.scheduleNextSync();
break;
default:
break;
}
@@ -40,4 +52,16 @@ export class MessagingMain {
});
*/
}
private scheduleNextSync() {
if (this.syncTimeout) {
global.clearTimeout(this.syncTimeout);
}
this.syncTimeout = global.setTimeout(() => {
this.windowMain.win.webContents.send('messagingService', {
command: 'checkSyncVault',
});
}, SyncInterval);
}
}