From 242c3e0c1171e5e19db9e41c0cd83d1b0da71604 Mon Sep 17 00:00:00 2001 From: TheGoddessInari Date: Sat, 4 Aug 2018 04:01:11 -0700 Subject: [PATCH] Remove auto-updating. We rip out the "smart" auto-updating and squirrel mechanism to be able to allow every platform to go directly to the github release page. --- app/Application.js | 8 ++---- electron/main.js | 72 +--------------------------------------------- 2 files changed, 4 insertions(+), 76 deletions(-) diff --git a/app/Application.js b/app/Application.js index c54025b5..f400d313 100644 --- a/app/Application.js +++ b/app/Application.js @@ -228,7 +228,7 @@ Ext.define('Rambox.Application', { ,checkUpdate: function(silence) { console.info('Checking for updates...'); Ext.Ajax.request({ - url: 'https://rambox.pro/api/latestversion.json' + url: 'https://api.github.com/repos/TheGoddessInari/rambox/releases/latest' ,method: 'GET' ,success: function(response) { var json = Ext.decode(response.responseText); @@ -243,13 +243,12 @@ Ext.define('Rambox.Application', { '->' ,{ xtype: 'label' - ,html: ''+locale['app.update[0]']+' ('+json.version+')' + ( process.platform === 'win32' ? ' is downloading in the background and you will be notified when it is ready to be installed.' : '' ) + ,html: ''+locale['app.update[0]']+' ('+json.version+')' } ,{ xtype: 'button' ,text: locale['app.update[1]'] - ,href: process.platform === 'darwin' ? 'https://getrambox.herokuapp.com/download/'+process.platform+'_'+process.arch : 'https://github.com/TheGoddessInari/rambox/releases/latest' - ,hidden: process.platform === 'win32' + ,href: process.platform === 'https://github.com/TheGoddessInari/rambox/releases/latest' } ,{ xtype: 'button' @@ -267,7 +266,6 @@ Ext.define('Rambox.Application', { } ] }); - if ( process.platform === 'win32' ) ipc.send('autoUpdater:check-for-updates'); return; } else if ( !silence ) { Ext.Msg.show({ diff --git a/electron/main.js b/electron/main.js index d705ca55..2f5f53ce 100644 --- a/electron/main.js +++ b/electron/main.js @@ -53,8 +53,7 @@ if (config.get('enable_hidpi_support') && (process.platform === 'win32')) { app.commandLine.appendSwitch('force-device-scale-factor', '1') } -// Because we build it using Squirrel, it will assign UserModelId automatically, so we match it here to display notifications correctly. -// https://github.com/electron-userland/electron-builder/issues/362 +// This must match the package name in package.json app.setAppUserModelId('com.thegoddessinari.rambox'); // Menu @@ -67,75 +66,6 @@ const appLauncher = new AutoLaunch({ }); config.get('auto_launch') && !isDev ? appLauncher.enable() : appLauncher.disable(); -// this should be placed at top of main.js to handle setup events quickly -if (handleSquirrelEvent()) { - // squirrel event handled and app will exit in 1000ms, so don't do anything else - return; -} - -function handleSquirrelEvent() { - if (process.argv.length === 1) { - return false; - } - - const ChildProcess = require('child_process'); - - const appFolder = path.resolve(process.execPath, '..'); - const rootAtomFolder = path.resolve(appFolder, '..'); - const updateDotExe = path.resolve(path.join(rootAtomFolder, 'Update.exe')); - const exeName = path.basename(process.execPath); - - const spawn = function(command, args) { - let spawnedProcess, error; - - try { - spawnedProcess = ChildProcess.spawn(command, args, {detached: true}); - } catch (error) {} - - return spawnedProcess; - }; - - const spawnUpdate = function(args) { - return spawn(updateDotExe, args); - }; - - const squirrelEvent = process.argv[1]; - switch (squirrelEvent) { - case '--squirrel-install': - case '--squirrel-updated': - // Optionally do things such as: - // - Add your .exe to the PATH - // - Write to the registry for things like file associations and - // explorer context menus - - // Install desktop and start menu shortcuts - spawnUpdate(['--createShortcut', exeName]); - - setTimeout(app.quit, 1000); - return true; - - case '--squirrel-uninstall': - // Undo anything you did in the --squirrel-install and - // --squirrel-updated handlers - - // Remove desktop and start menu shortcuts - spawnUpdate(['--removeShortcut', exeName]); - // Remove user app data - require('rimraf').sync(require('electron').app.getPath('userData')); - - setTimeout(app.quit, 1000); - return true; - - case '--squirrel-obsolete': - // This is called on the outgoing version of your app before - // we update to the new version - it's the opposite of - // --squirrel-updated - - app.quit(); - return true; - } -}; - // Keep a global reference of the window object, if you don't, the window will // be closed automatically when the JavaScript object is garbage collected. let mainWindow;