-
Notifications
You must be signed in to change notification settings - Fork 477
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #146 from hql287/auto-check-for-update
Added auto check for update
- Loading branch information
Showing
4 changed files
with
58 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Libs | ||
const { BrowserWindow, ipcMain } = require('electron'); | ||
const { autoUpdater } = require('electron-updater'); | ||
const { checkForUpdate } = require('./updater'); | ||
const appConfig = require('electron-settings'); | ||
|
||
const checkUpdate = appConfig.get('general.checkUpdate'); | ||
const lastCheck = appConfig.get('general.lastCheck'); | ||
const now = Date.now(); | ||
|
||
const daysSinceLastCheck = Math.round( | ||
Math.abs(now - lastCheck) / (1000 * 60 * 60 * 24) | ||
); | ||
|
||
if (checkUpdate === 'daily' && daysSinceLastCheck >= 1) { | ||
checkForUpdate(); | ||
appConfig.set('general.lastCheck', Date.now()); // Reset last check timeStamp | ||
} | ||
|
||
if (checkUpdate === 'weekly' && daysSinceLastCheck >= 7) { | ||
checkForUpdate(); | ||
appConfig.set('general.lastCheck', Date.now()); // Reset last check timeStamp | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters