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

If crashing within first 2min don't lose windows #10381

Merged
merged 1 commit into from
Aug 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
})
})
})