Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Merge pull request #10381 from brave/10349
Browse files Browse the repository at this point in the history
If crashing within first 2min don't lose windows
  • Loading branch information
bbondy authored Aug 10, 2017
2 parents e3e2855 + 9145373 commit 2634bbf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
5 changes: 2 additions & 3 deletions app/sessionStoreShutdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,12 @@ app.on('before-quit', (e) => {
if (sessionStateSaveInterval !== undefined) {
clearInterval(sessionStateSaveInterval)
}
initiateSessionStateSave()
module.exports.initiateSessionStateSave()
})

const startSessionSaveInterval = () => {
// save app state every 5 minutes regardless of update frequency
initiateSessionStateSave()
sessionStateSaveInterval = setInterval(initiateSessionStateSave, appConfig.sessionSaveInterval)
sessionStateSaveInterval = setInterval(module.exports.initiateSessionStateSave, appConfig.sessionSaveInterval)
}

// User initiated exit using File->Quit
Expand Down
14 changes: 14 additions & 0 deletions test/unit/app/sessionStoreShutdownTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,4 +355,18 @@ describe('sessionStoreShutdown unit tests', function () {
})
})
})
describe('startSessionSaveInterval', function () {
before(function () {
this.initiateSessionStateSave = sinon.spy(sessionStoreShutdown, 'initiateSessionStateSave')
})
after(function () {
this.initiateSessionStateSave.restore()
})
// We only care that initiateSessionStateSave is not called sync.
// Windows will be initialized for the non sync case.
it('does not call initiateSessionStateSave', function () {
sessionStoreShutdown.startSessionSaveInterval()
assert.equal(this.initiateSessionStateSave.notCalled, true)
})
})
})

0 comments on commit 2634bbf

Please sign in to comment.