mirror of
https://github.com/element-hq/element-web
synced 2024-11-24 18:25:49 +03:00
Make auto-update configureable
Otherwise everyone that builds electron vector will end up with their apps auto-updatin to our version when we release an update. Coming next: A way to manage our electron release process to make sure we never ship a build with auto-update disabled.
This commit is contained in:
parent
0441fcf3df
commit
84aac88677
1 changed files with 38 additions and 15 deletions
|
@ -28,6 +28,17 @@ const url = require('url');
|
||||||
|
|
||||||
const VectorMenu = require('./vectormenu');
|
const VectorMenu = require('./vectormenu');
|
||||||
|
|
||||||
|
let vectorConfig = {};
|
||||||
|
try {
|
||||||
|
vectorConfig = require('../../vector/config.json');
|
||||||
|
} catch (e) {
|
||||||
|
console.log(`file://${__dirname}/../../vector/config.json`, e);
|
||||||
|
// it would be nice to check the error code here and bail if the config
|
||||||
|
// is unparseable, but we get MODULE_NOT_FOUND in the case of a missing
|
||||||
|
// file or invalid json, so node is just very unhelpful.
|
||||||
|
// Continue with the defaults (ie. an empty config)
|
||||||
|
}
|
||||||
|
|
||||||
const PERMITTED_URL_SCHEMES = [
|
const PERMITTED_URL_SCHEMES = [
|
||||||
'http:',
|
'http:',
|
||||||
'https:',
|
'https:',
|
||||||
|
@ -91,19 +102,10 @@ function pollForUpdates() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle uncaught errors otherwise it displays
|
function startAutoUpdate(update_url) {
|
||||||
// stack traces in popup dialogs, which is terrible (which
|
if (update_url.slice(-1) !== '/') {
|
||||||
// it will do any time the auto update poke fails, and there's
|
update_url = update_url + '/';
|
||||||
// no other way to catch this error).
|
}
|
||||||
// Assuming we generally run from the console when developing,
|
|
||||||
// this is far preferable.
|
|
||||||
process.on('uncaughtException', function (error) {
|
|
||||||
console.log("Unhandled exception", error);
|
|
||||||
});
|
|
||||||
|
|
||||||
electron.ipcMain.on('install_update', installUpdate);
|
|
||||||
|
|
||||||
electron.app.on('ready', () => {
|
|
||||||
try {
|
try {
|
||||||
// For reasons best known to Squirrel, the way it checks for updates
|
// For reasons best known to Squirrel, the way it checks for updates
|
||||||
// is completely different between macOS and windows. On macOS, it
|
// is completely different between macOS and windows. On macOS, it
|
||||||
|
@ -111,9 +113,9 @@ electron.app.on('ready', () => {
|
||||||
// 204 No Content. On windows it takes a base path and looks for
|
// 204 No Content. On windows it takes a base path and looks for
|
||||||
// files under that path.
|
// files under that path.
|
||||||
if (process.platform == 'darwin') {
|
if (process.platform == 'darwin') {
|
||||||
electron.autoUpdater.setFeedURL("https://riot.im/autoupdate/desktop/");
|
electron.autoUpdater.setFeedURL(update_url);
|
||||||
} else if (process.platform == 'win32') {
|
} else if (process.platform == 'win32') {
|
||||||
electron.autoUpdater.setFeedURL("https://riot.im/download/desktop/win32/");
|
electron.autoUpdater.setFeedURL(update_url + 'win32/');
|
||||||
} else {
|
} else {
|
||||||
// Squirrel / electron only supports auto-update on these two platforms.
|
// Squirrel / electron only supports auto-update on these two platforms.
|
||||||
// I'm not even going to try to guess which feed style they'd use if they
|
// I'm not even going to try to guess which feed style they'd use if they
|
||||||
|
@ -133,6 +135,27 @@ electron.app.on('ready', () => {
|
||||||
// will fail if running in debug mode
|
// will fail if running in debug mode
|
||||||
console.log("Couldn't enable update checking", err);
|
console.log("Couldn't enable update checking", err);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// handle uncaught errors otherwise it displays
|
||||||
|
// stack traces in popup dialogs, which is terrible (which
|
||||||
|
// it will do any time the auto update poke fails, and there's
|
||||||
|
// no other way to catch this error).
|
||||||
|
// Assuming we generally run from the console when developing,
|
||||||
|
// this is far preferable.
|
||||||
|
process.on('uncaughtException', function (error) {
|
||||||
|
console.log("Unhandled exception", error);
|
||||||
|
});
|
||||||
|
|
||||||
|
electron.ipcMain.on('install_update', installUpdate);
|
||||||
|
|
||||||
|
electron.app.on('ready', () => {
|
||||||
|
if (vectorConfig.update_url) {
|
||||||
|
console.log("Starting auto update with URL: " + vectorConfig.update_url);
|
||||||
|
startAutoUpdate(vectorConfig.update_url);
|
||||||
|
} else {
|
||||||
|
console.log("No update_url is defined: auto update is disabled");
|
||||||
|
}
|
||||||
|
|
||||||
mainWindow = new electron.BrowserWindow({
|
mainWindow = new electron.BrowserWindow({
|
||||||
icon: `${__dirname}/../img/riot.ico`,
|
icon: `${__dirname}/../img/riot.ico`,
|
||||||
|
|
Loading…
Reference in a new issue