diff --git a/app.js b/app.js
index 069c918b..f6ca2716 100644
--- a/app.js
+++ b/app.js
@@ -300,6 +300,18 @@ function migrateData() {
})
});
},
+
+ 3: configs => {
+ // Return current configs if checkUpdate and lastCheck do not exist
+ const { checkUpdate, lastCheck} = configs.general;
+ if ( checkUpdate === undefined || lastCheck === undefined ) {
+ return configs;
+ }
+ // Remove checkUpdate and lastCheck
+ return Object.assign({}, configs, {
+ general: omit(configs.general, ['checkUpdate', 'lastCheck'])
+ });
+ },
};
// Get the current Config
const configs = appConfig.getAll();
diff --git a/app/components/settings/General.jsx b/app/components/settings/General.jsx
index 20b7a682..0336ecc1 100644
--- a/app/components/settings/General.jsx
+++ b/app/components/settings/General.jsx
@@ -61,14 +61,18 @@ class General extends Component {
-
+
@@ -87,25 +91,6 @@ class General extends Component {
-
-
-
-
-
-
-
-
);
}
diff --git a/main/auto-check-updates.js b/main/auto-check-updates.js
deleted file mode 100644
index c4745ab5..00000000
--- a/main/auto-check-updates.js
+++ /dev/null
@@ -1,23 +0,0 @@
-// 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
-}
diff --git a/main/updater.js b/main/updater.js
index 7c232119..bf0c14c0 100644
--- a/main/updater.js
+++ b/main/updater.js
@@ -4,23 +4,22 @@ const { autoUpdater } = require('electron-updater');
const appConfig = require('electron-settings');
const isDev = require('electron-is-dev');
+// Set mainWindow
+const mainWindowID = appConfig.get('mainWindowID');
+const mainWindow = BrowserWindow.fromId(mainWindowID);
+
// Disable Auto Downloading update;
autoUpdater.autoDownload = false;
// Check for update silently
let silentMode = true;
-// Set mainWindow
-const mainWindowID = appConfig.get('mainWindowID');
-const mainWindow = BrowserWindow.fromId(mainWindowID);
-
- // Check for Updates
-ipcMain.on('check-for-updates', (event) => {
- if(!isDev) {
- // Turn off silent mode
- silentMode = false;
- checkForUpdate();
- }
+// HANDLING IPC
+// Check for updates manually
+ipcMain.on('check-for-updates', event => {
+ // Turn off silent mode first
+ silentMode = false;
+ checkForUpdate();
});
// Start Download
@@ -28,8 +27,7 @@ ipcMain.on('update-download-started', () => {
autoUpdater.downloadUpdate();
});
-// All AutoUpdater Events
-// ====================================
+// CHECKING FOR UPDATE EVENTS
// Checking for Update
autoUpdater.on('checking-for-update', () => {
// Only notice user when they checked manually
@@ -58,10 +56,11 @@ autoUpdater.on('error', error => {
errMessage = 'Unknown Error';
} else {
errMessage = error.message;
- }
+ };
mainWindow.send('update-error', errMessage);
});
+// DOWNLOADING UPDATE EVENTS
// Download Progress
autoUpdater.on('download-progress', progressObj => {
mainWindow.send('update-download-progress', progressObj.percent);
@@ -72,11 +71,13 @@ autoUpdater.on('update-downloaded', info => {
mainWindow.send('update-downloaded', info);
});
-// Helper
+// Main Function
function checkForUpdate() {
- autoUpdater.checkForUpdates();
+ // Only check for update in Production
+ if (!isDev) {
+ autoUpdater.checkForUpdates();
+ }
}
-module.exports = {
- checkForUpdate,
-};
+// Check for update on Startup
+checkForUpdate();