Skip to content

Commit

Permalink
Simplify persist
Browse files Browse the repository at this point in the history
  • Loading branch information
floating committed Aug 14, 2021
1 parent ca09516 commit b25c1bd
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions main/store/persist/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const path = require('path')
const electron = require('electron')
const Conf = require('conf')
const log = require('electron-log')

const migrations = require('../migrations')

Expand All @@ -17,6 +16,7 @@ class PersistStore extends Conf {
}
electron.app.on('quit', () => this.writeUpdates())
super(options)
setInterval(() => this.writeUpdates(), 30 * 1000)
}

writeUpdates () {
Expand All @@ -28,9 +28,8 @@ class PersistStore extends Conf {
queue (path, value) {
path = `main.__.${migrations.latest}.${path}`
this.updates = this.updates || {}
delete this.updates[path] // maintain entry order
this.updates[path] = JSON.parse(JSON.stringify(value))
if (Object.keys(this.updates).length < 75) clearTimeout(this.updateTimer)
this.updateTimer = setTimeout(() => this.writeUpdates(), 4000)
}

set (path, value) {
Expand Down

0 comments on commit b25c1bd

Please sign in to comment.