Browse Source

Auto Updater

Fixed #127
pull/223/head
Ramiro Saenz 9 years ago
parent
commit
72c83984a9
  1. 3
      app.js
  2. 89
      app/Application.js
  3. 2
      app/package.json
  4. 2
      electron/main.js
  5. 18
      electron/menu.js
  6. 17
      package.json

3
app.js

@ -32,6 +32,9 @@ ipc.on('showAbout', function(event, message) {
ipc.on('autoUpdater:checking-for-update:', function() { ipc.on('autoUpdater:checking-for-update:', function() {
Ext.Msg.wait('Please wait...', 'Checking for update'); Ext.Msg.wait('Please wait...', 'Checking for update');
}); });
ipc.on('autoUpdater:check-update', function() {
Rambox.app.checkUpdate();
});
ipc.on('autoUpdater:update-not-available', function() { ipc.on('autoUpdater:update-not-available', function() {
Ext.Msg.show({ Ext.Msg.show({
title: 'You are up to date!' title: 'You are up to date!'

89
app/Application.js

@ -126,45 +126,8 @@ Ext.define('Rambox.Application', {
] ]
}); });
if ( process.platform !== 'win32' && process.platform !== 'darwin' ) { if ( process.platform !== 'win32' ) {
fireRef.database().ref('config').on('value', function(snapshot) { this.checkUpdate(true);
var appVersion = new Ext.Version(require('electron').remote.app.getVersion());
if ( appVersion.isLessThan(snapshot.val().latestVersion) ) {
console.info('New version is available', snapshot.val().latestVersion);
Ext.cq1('app-main').addDocked({
xtype: 'toolbar'
,dock: 'top'
,ui: 'newversion'
,items: [
'->'
,{
xtype: 'label'
,html: '<b>New version is available!</b> ('+snapshot.val().latestVersion+')'
}
,{
xtype: 'button'
,text: 'Download'
,href: 'https://getrambox.herokuapp.com/download/'+process.platform+'_'+process.arch
}
,{
xtype: 'button'
,text: 'Changelog'
,href: 'https://github.com/saenzramiro/rambox/releases/tag/'+snapshot.val().latestVersion
}
,'->'
,{
glyph: 'xf00d@FontAwesome'
,baseCls: ''
,style: 'cursor:pointer;'
,handler: function(btn) { Ext.cq1('app-main').removeDocked(btn.up('toolbar'), true); }
}
]
});
return;
}
console.info('Your version is the latest. No need to update.')
});
} }
if ( localStorage.getItem('locked') ) { if ( localStorage.getItem('locked') ) {
@ -184,4 +147,52 @@ Ext.define('Rambox.Application', {
document.title = 'Rambox'; document.title = 'Rambox';
} }
} }
,checkUpdate: function(silence) {
fireRef.database().ref('config').once('value', function(snapshot) {
var appVersion = new Ext.Version(require('electron').remote.app.getVersion());
if ( appVersion.isLessThan(snapshot.val().latestVersion) ) {
console.info('New version is available', snapshot.val().latestVersion);
Ext.cq1('app-main').addDocked({
xtype: 'toolbar'
,dock: 'top'
,ui: 'newversion'
,items: [
'->'
,{
xtype: 'label'
,html: '<b>New version is available!</b> ('+snapshot.val().latestVersion+')'
}
,{
xtype: 'button'
,text: 'Download'
,href: 'https://getrambox.herokuapp.com/download/'+process.platform+'_'+process.arch
}
,{
xtype: 'button'
,text: 'Changelog'
,href: 'https://github.com/saenzramiro/rambox/releases/tag/'+snapshot.val().latestVersion
}
,'->'
,{
glyph: 'xf00d@FontAwesome'
,baseCls: ''
,style: 'cursor:pointer;'
,handler: function(btn) { Ext.cq1('app-main').removeDocked(btn.up('toolbar'), true); }
}
]
});
return;
} else if ( !silence ) {
Ext.Msg.show({
title: 'You are up to date!'
,message: 'You have the latest version of Rambox.'
,icon: Ext.Msg.INFO
,buttons: Ext.Msg.OK
});
}
console.info('Your version is the latest. No need to update.');
});
}
}); });

2
app/package.json

@ -1,7 +1,7 @@
{ {
"name": "rambox", "name": "rambox",
"productName": "Rambox", "productName": "Rambox",
"version": "0.4.1", "version": "0.3.0",
"description": "Free and Open Source messaging and emailing app that combines common web applications into one.", "description": "Free and Open Source messaging and emailing app that combines common web applications into one.",
"main": "electron/main.js", "main": "electron/main.js",
"private": true, "private": true,

2
electron/main.js

@ -132,7 +132,7 @@ function createWindow () {
tray.create(mainWindow, mainWindowState); tray.create(mainWindow, mainWindowState);
if ( !isDev ) updater.initialize(mainWindow); if ( !isDev && process.platform === 'win32' ) updater.initialize(mainWindow);
mainWindow.on('page-title-updated', (e, title) => updateBadge(title)); mainWindow.on('page-title-updated', (e, title) => updateBadge(title));

18
electron/menu.js

@ -309,6 +309,14 @@ if (process.platform === 'darwin') {
tpl.unshift({ tpl.unshift({
label: appName, label: appName,
submenu: [ submenu: [
{
label: `Check for updates...`,
click(item, win) {
const webContents = win.webContents;
const send = webContents.send.bind(win.webContents);
send('autoUpdater:check-update');
}
},
{ {
label: `About ${appName}`, label: `About ${appName}`,
click() { click() {
@ -387,9 +395,13 @@ if (process.platform === 'darwin') {
click(item, win) { click(item, win) {
const webContents = win.webContents; const webContents = win.webContents;
const send = webContents.send.bind(win.webContents); const send = webContents.send.bind(win.webContents);
electron.autoUpdater.checkForUpdates(); if ( process.platform === 'win32' ) {
electron.autoUpdater.once('update-available', (event) => send('autoUpdater:update-available')); electron.autoUpdater.checkForUpdates();
electron.autoUpdater.once('update-not-available', (event) => send('autoUpdater:update-not-available')); electron.autoUpdater.once('update-available', (event) => send('autoUpdater:update-available'));
electron.autoUpdater.once('update-not-available', (event) => send('autoUpdater:update-not-available'));
} else {
send('autoUpdater:check-update');
}
} }
}); });
helpSubmenu.push({ helpSubmenu.push({

17
package.json

@ -18,7 +18,7 @@
"pack:linux32": "electron-packager \"./build/production/Rambox/\" \"Rambox\" --out=dist --platform=linux --arch=ia32 --version=1.3.1 --icon=resources/installer/Icon.ico --app-version=0.2.0 --build-version=64-bit --version-string.CompanyName=\"Rambox\" --version-string.ProductName=\"Rambox\" --asar --prune --overwrite", "pack:linux32": "electron-packager \"./build/production/Rambox/\" \"Rambox\" --out=dist --platform=linux --arch=ia32 --version=1.3.1 --icon=resources/installer/Icon.ico --app-version=0.2.0 --build-version=64-bit --version-string.CompanyName=\"Rambox\" --version-string.ProductName=\"Rambox\" --asar --prune --overwrite",
"pack:linux64": "electron-packager \"./build/production/Rambox/\" \"Rambox\" --out=dist --platform=linux --arch=x64 --version=1.3.1 --icon=resources/installer/Icon.ico --app-version=0.2.0 --build-version=64-bit --version-string.CompanyName=\"Rambox\" --version-string.ProductName=\"Rambox\" --asar --prune --overwrite", "pack:linux64": "electron-packager \"./build/production/Rambox/\" \"Rambox\" --out=dist --platform=linux --arch=x64 --version=1.3.1 --icon=resources/installer/Icon.ico --app-version=0.2.0 --build-version=64-bit --version-string.CompanyName=\"Rambox\" --version-string.ProductName=\"Rambox\" --asar --prune --overwrite",
"build": "npm run build:linux && npm run build:osx && npm run build:win", "build": "npm run build:linux && npm run build:osx && npm run build:win",
"build:osx": "build \"dist/Rambox-darwin-x64/Rambox.app\" --platform=osx", "build:osx": "build --osx",
"build:linux": "npm run build:linux32 && npm run build:linux64", "build:linux": "npm run build:linux32 && npm run build:linux64",
"build:linux32": "build --linux --ia32", "build:linux32": "build --linux --ia32",
"build:linux64": "build --linux --x64", "build:linux64": "build --linux --x64",
@ -52,8 +52,15 @@
"schemes": ["rambox"] "schemes": ["rambox"]
} }
], ],
"mac": {
"target": [
"default"
],
"icon": "./resources/installer/Icon.icns"
},
"dmg": { "dmg": {
"title": "Rambox", "title": "Rambox",
"icon": "./resources/installer/Icon.icns",
"icon-size": 128, "icon-size": 128,
"contents": [ "contents": [
{ {
@ -102,13 +109,9 @@
"devDependencies": { "devDependencies": {
"asar": "^0.12.1", "asar": "^0.12.1",
"bestzip": "^1.1.3", "bestzip": "^1.1.3",
"electron-builder": "5.17.0", "electron-builder": "5.19.1",
"electron-installer-windows": "^0.2.0",
"electron-packager": "7.3.0",
"electron-prebuilt": "1.3.1", "electron-prebuilt": "1.3.1",
"electron-squirrel-startup": "^1.0.0", "electron-squirrel-startup": "^1.0.0"
"electron-winstaller": "^2.3.0",
"spectron": "^3.2.3"
}, },
"config": { "config": {
"pre-git": { "pre-git": {

Loading…
Cancel
Save