Add enableAutoUpdater to buildConfig

This commit is contained in:
Yuya Ochiai
2017-11-28 23:54:11 +09:00
parent e6105938ea
commit 0bec4ab5a3
3 changed files with 23 additions and 16 deletions

View File

@@ -24,6 +24,7 @@ const buildConfig = {
],
helpLink: 'https://about.mattermost.com/default-desktop-app-documentation/',
enableServerManagement: true,
enableAutoUpdater: true,
};
export default buildConfig;

View File

@@ -26,6 +26,7 @@ import {protocols} from '../electron-builder.json';
import CriticalErrorHandler from './main/CriticalErrorHandler';
import {upgradeAutoLaunch} from './main/autoLaunch';
import buildConfig from './common/config/buildConfig';
const criticalErrorHandler = new CriticalErrorHandler();
@@ -636,18 +637,20 @@ app.on('ready', () => {
permissionManager = new PermissionManager(permissionFile, trustedURLs);
session.defaultSession.setPermissionRequestHandler(permissionRequestHandler(mainWindow, permissionManager));
const updaterConfig = autoUpdater.loadConfig(path.resolve(app.getAppPath(), '../app-updater-config.json'));
autoUpdater.initialize(appState, mainWindow, updaterConfig.isNotifyOnly());
ipcMain.on('check-for-updates', autoUpdater.checkForUpdates);
mainWindow.once('show', () => {
if (autoUpdater.shouldCheckForUpdatesOnStart(appState.updateCheckedDate)) {
ipcMain.emit('check-for-updates');
} else {
setTimeout(() => {
if (buildConfig.enableAutoUpdater) {
const updaterConfig = autoUpdater.loadConfig(path.resolve(app.getAppPath(), '../app-updater-config.json'));
autoUpdater.initialize(appState, mainWindow, updaterConfig.isNotifyOnly());
ipcMain.on('check-for-updates', autoUpdater.checkForUpdates);
mainWindow.once('show', () => {
if (autoUpdater.shouldCheckForUpdatesOnStart(appState.updateCheckedDate)) {
ipcMain.emit('check-for-updates');
}, autoUpdater.INTERVAL_48_HOURS_IN_MS);
}
});
} else {
setTimeout(() => {
ipcMain.emit('check-for-updates');
}, autoUpdater.INTERVAL_48_HOURS_IN_MS);
}
});
}
// Open the DevTools.
// mainWindow.openDevTools();

View File

@@ -230,12 +230,15 @@ function createTemplate(mainWindow, config, isDev) {
submenu.push({
label: `Version ${app.getVersion()}`,
enabled: false,
}, {
label: 'Check for Updates...',
click() {
ipcMain.emit('check-for-updates', true);
},
});
if (buildConfig.enableAutoUpdater) {
submenu.push({
label: 'Check for Updates...',
click() {
ipcMain.emit('check-for-updates', true);
},
});
}
template.push({label: '&Help', submenu});
return template;
}