Browse Source

Improved synchronization and check for updates

- Removed Firebase and start using Auth0 Metadata to store users
services.
- Instead of getting latest version from Firebase, now get it from
GitHub.
pull/591/head
Ramiro Saenz 8 years ago
parent
commit
71b918f65e
  1. 14
      app.js
  2. 25
      app/Application.js
  3. 3
      app/model/Service.js
  4. 2
      app/package.json
  5. 2
      app/profile/Online.js
  6. 45
      app/store/Services.js
  7. 176
      app/ux/Auth0.js
  8. 170
      app/ux/Firebase.js
  9. 31
      app/view/main/Main.js
  10. 7
      app/view/main/MainController.js
  11. 1
      app/view/main/MainModel.js
  12. 6
      electron/menu.js
  13. 2
      electron/updater.js
  14. 3
      package.json

14
app.js

@ -1,17 +1,3 @@
// Initialize Firebase
var firebase = require('firebase/app');
require('firebase/database');
require('firebase/auth');
// Firebase Config
var config = {
apiKey: firebaseCfg.apiKey
,authDomain: firebaseCfg.authDomain
,databaseURL: firebaseCfg.databaseURL
,storageBucket: firebaseCfg.storageBucket
};
var fireRef = firebase.initializeApp(config); // Firebase Ref
var FirebaseTokenGenerator = require('firebase-token-generator');
var auth0, lock; // Auth0 vars var auth0, lock; // Auth0 vars
// Sencha App // Sencha App

25
app/Application.js

@ -4,8 +4,7 @@ Ext.define('Rambox.Application', {
,name: 'Rambox' ,name: 'Rambox'
,requires: [ ,requires: [
'Rambox.ux.Firebase' 'Rambox.ux.Auth0'
,'Rambox.ux.Auth0'
,'Rambox.util.MD5' ,'Rambox.util.MD5'
,'Ext.window.Toast' ,'Ext.window.Toast'
] ]
@ -31,6 +30,12 @@ Ext.define('Rambox.Application', {
ga_storage._trackPageview('/index.html', 'main'); ga_storage._trackPageview('/index.html', 'main');
ga_storage._trackEvent('Versions', require('electron').remote.app.getVersion()); ga_storage._trackEvent('Versions', require('electron').remote.app.getVersion());
// Initialize Auth0
Rambox.ux.Auth0.init();
// Check for updates
Rambox.app.checkUpdate(true);
// Add shortcuts to switch services using CTRL + Number // Add shortcuts to switch services using CTRL + Number
var map = new Ext.util.KeyMap({ var map = new Ext.util.KeyMap({
target: document target: document
@ -204,10 +209,15 @@ Ext.define('Rambox.Application', {
} }
,checkUpdate: function(silence) { ,checkUpdate: function(silence) {
fireRef.database().ref('config').once('value', function(snapshot) { console.info('Checking for updates...');
Ext.Ajax.request({
url: 'http://rambox.pro/api/latestversion.json'
,method: 'GET'
,success: function(response) {
var json = Ext.decode(response.responseText);
var appVersion = new Ext.Version(require('electron').remote.app.getVersion()); var appVersion = new Ext.Version(require('electron').remote.app.getVersion());
if ( appVersion.isLessThan(snapshot.val().latestVersion) ) { if ( appVersion.isLessThan(json.version) ) {
console.info('New version is available', snapshot.val().latestVersion); console.info('New version is available', json.version);
Ext.cq1('app-main').addDocked({ Ext.cq1('app-main').addDocked({
xtype: 'toolbar' xtype: 'toolbar'
,dock: 'top' ,dock: 'top'
@ -216,7 +226,7 @@ Ext.define('Rambox.Application', {
'->' '->'
,{ ,{
xtype: 'label' xtype: 'label'
,html: '<b>New version is available!</b> ('+snapshot.val().latestVersion+')' + ( process.platform === 'win32' ? ' Is downloading in the background and you will notify when is ready to install it.' : '' ) ,html: '<b>New version is available!</b> ('+json.version+')' + ( process.platform === 'win32' ? ' Is downloading in the background and you will notify when is ready to install it.' : '' )
} }
,{ ,{
xtype: 'button' xtype: 'button'
@ -229,7 +239,7 @@ Ext.define('Rambox.Application', {
,text: 'Changelog' ,text: 'Changelog'
,ui: 'decline' ,ui: 'decline'
,tooltip: 'Click here to see more information about the new version.' ,tooltip: 'Click here to see more information about the new version.'
,href: 'https://github.com/saenzramiro/rambox/releases/tag/'+snapshot.val().latestVersion ,href: 'https://github.com/saenzramiro/rambox/releases/tag/'+json.version
} }
,'->' ,'->'
,{ ,{
@ -252,6 +262,7 @@ Ext.define('Rambox.Application', {
} }
console.info('Your version is the latest. No need to update.'); console.info('Your version is the latest. No need to update.');
}
}); });
} }
}); });

3
app/model/Service.js

@ -60,8 +60,5 @@ Ext.define('Rambox.model.Service', {
name: 'js_unread' name: 'js_unread'
,type: 'string' ,type: 'string'
,defaultValue: '' ,defaultValue: ''
},{
name: 'firebase_key'
,type: 'int'
}] }]
}); });

2
app/package.json

@ -30,8 +30,6 @@
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"auto-launch": "4.0.0", "auto-launch": "4.0.0",
"firebase": "^3.0.5",
"firebase-token-generator": "^2.0.0",
"tmp": "0.0.28", "tmp": "0.0.28",
"electron-spell-check-provider": "^1.0.0", "electron-spell-check-provider": "^1.0.0",
"mime": "^1.3.4", "mime": "^1.3.4",

2
app/profile/Online.js

@ -6,7 +6,5 @@ Ext.define('Rambox.profile.Online', {
,launch: function() { ,launch: function() {
console.info('USER LOGGED IN'); console.info('USER LOGGED IN');
Rambox.ux.Firebase.createEvents(false);
} }
}); });

45
app/store/Services.js

@ -65,50 +65,5 @@ Ext.define('Rambox.store.Services', {
store.suspendEvent('load'); store.suspendEvent('load');
Ext.cq1('app-main').resumeEvent('add'); Ext.cq1('app-main').resumeEvent('add');
} }
,add: function(store, records, index) {
var record = records[0];
if ( !localStorage.getItem('id_token') || (!Ext.isEmpty(record.previousValues) && !Ext.isEmpty(record.previousValues.position)) ) return true;
console.info('Saving into Firebase...', record.data);
var ref = fireRef.database().ref('users/' + Ext.decode(localStorage.getItem('profile')).user_id).child('services');
ref.once('value', function(snap) {
// Generate Key
var i = 0;
while ( snap.child(i).exists() ) { i++; }
// Save Firebase Key into record
record.set('firebase_key', i);
// Prevent saving local ID and Firebase Key into Firebase
var data = Ext.clone(record.data);
delete data.id;
delete data.firebase_key;
// Make the call
ref.child(i).set(data);
});
}
,update: function(store, record, operation, data) {
// Is not logged, Skip
if ( !localStorage.getItem('id_token') || operation === 'commit' ) return;
if ( operation === 'edit' && data[0] !== 'firebase_key' ) {
var obj = {};
Ext.each(data, function(prop) {
obj[prop] = record.get(prop);
});
fireRef.database().ref('users/' + Ext.decode(localStorage.getItem('profile')).user_id + '/services').child(record.get('firebase_key')).update(obj);
}
}
,remove: function(store, records, index, isMove) {
if ( !localStorage.getItem('id_token') ) return;
Ext.each(records, function(rec) {
fireRef.database().ref('users/' + Ext.decode(localStorage.getItem('profile')).user_id).child('services').child(rec.get('firebase_key')).remove();
});
}
} }
}); });

176
app/ux/Auth0.js

@ -41,131 +41,129 @@ Ext.define('Rambox.ux.Auth0', {
return; return;
} }
console.log('LOGIN', err, profile, authResult.idToken);
// Display a spinner while waiting // Display a spinner while waiting
Ext.Msg.wait('Please wait until we get your configuration.', 'Connecting...'); Ext.Msg.wait('Please wait until we get your configuration.', 'Connecting...');
// Google Analytics Event // Google Analytics Event
ga_storage._trackEvent('Users', 'loggedIn'); ga_storage._trackEvent('Users', 'loggedIn');
// Set the options to retreive a firebase delegation token // User is logged in
var options = { // Save the profile and JWT.
id_token: authResult.idToken localStorage.setItem('profile', JSON.stringify(profile));
,api: 'firebase' localStorage.setItem('id_token', authResult.idToken);
,scope: 'openid name email displayName'
,target: auth0Cfg.clientID
};
// Make a call to the Auth0 '/delegate'
me.auth0.getDelegationToken(options, function(err, result) {
if ( !err ) {
// Exchange the delegate token for a Firebase auth token
firebase.auth().signInWithCustomToken(result.id_token).then(function(snapshot) {
fireRef.database().ref('users/' + profile.user_id).child('services').orderByChild('position').once('value', function(snapshot2) {
Ext.Msg.hide();
// Import Services function if ( !Ext.isEmpty(profile.user_metadata.services) ) {
var importServices = function(snap) { Ext.each(profile.user_metadata.services, function(s) {
snap.forEach(function(data) {
var s = data.val();
s.firebase_key = data.key;
var service = Ext.create('Rambox.model.Service', s); var service = Ext.create('Rambox.model.Service', s);
service.save(); service.save();
Ext.getStore('Services').add(service); Ext.getStore('Services').add(service);
}); });
Ext.getStore('Services').resumeEvent('load');
Ext.getStore('Services').load();
// User is logged in require('electron').remote.getCurrentWindow().reload();
// Save the profile and JWT.
localStorage.setItem('profile', JSON.stringify(profile));
localStorage.setItem('id_token', authResult.idToken);
// Define Events for Firebase
Rambox.ux.Firebase.createEvents();
} }
// Firebase empty and Have Services Ext.Msg.hide();
if ( !snapshot2.hasChildren() && Ext.getStore('Services').getCount() > 0 ) { Ext.cq1('app-main').getViewModel().set('username', profile.name);
Ext.Msg.confirm('Import', 'You don\'t have any service saved. Do you want to import your current services?', function(btnId) { Ext.cq1('app-main').getViewModel().set('avatar', profile.picture);
if ( btnId === 'yes' ) {
var services = [];
Ext.getStore('Services').each(function(service, index) {
service.set('firebase_key', index);
// Prevent saving local ID into Firebase
var data = Ext.clone(service.data);
delete data.id;
services.push(data);
}); });
fireRef.database().ref('users/' + profile.user_id).set({
services: services
}); });
}
// User is logged in ,backupConfiguration: function() {
// Save the profile and JWT. var me = this;
localStorage.setItem('profile', JSON.stringify(profile));
localStorage.setItem('id_token', authResult.idToken);
// Define Events for Firebase Ext.Msg.wait('Saving backup...', 'Please wait...');
Rambox.ux.Firebase.createEvents();
} else { // Getting all services
Ext.Msg.confirm('Clear services', 'Do you want to remove all your current services to start over?<br /><br />If <b>NO</b>, you will be logged out.', function(btnId) { var lastupdate = (new Date()).toJSON();
if ( btnId === 'yes' ) { var services = [];
Ext.cq1('app-main').getController().removeAllServices(false); Ext.getStore('Services').each(function(service) {
} else { delete service.data.id;
me.logout(); services.push(service.data);
}
}); });
}
Ext.Ajax.request({
url: 'https://rambox.auth0.com/api/v2/users/'+Ext.decode(localStorage.getItem('profile')).user_id
,method: 'PATCH'
,headers: { authorization: "Bearer " + localStorage.getItem('id_token') }
,jsonData: { user_metadata: { services: services, services_lastupdate: lastupdate } }
,success: function(response) {
Ext.Msg.hide();
// Save the last update in localStorage
var profile = Ext.decode(localStorage.getItem('profile'));
profile.user_metadata.services_lastupdate = lastupdate;
localStorage.setItem('profile', Ext.encode(profile));
Ext.cq1('app-main').getViewModel().set('last_sync', new Date(lastupdate).toUTCString());
Ext.toast({
html: '<i class="fa fa-check fa-3x fa-pull-left" aria-hidden="true"></i> Your configuration were successfully backed up.'
,title: 'Synchronize Configuration'
,width: 300
,align: 't'
,closable: false
}); });
// Firebase not empty and Have Services }
} else if ( snapshot2.hasChildren() && Ext.getStore('Services').getCount() > 0 ) { ,failure: function(response) {
Ext.Msg.confirm('Confirm', 'To import your configuration, I need to remove all your current services. Do you want to continue?<br /><br />If <b>NO</b>, you will be logged out.', function(btnId) { Ext.Msg.hide();
if ( btnId === 'yes' ) { Ext.toast({
Ext.cq1('app-main').getController().removeAllServices(false, function() { html: '<i class="fa fa-times fa-3x fa-pull-left" aria-hidden="true"></i> Error ocurred when trying to backup your configuration.'
importServices(snapshot2); ,title: 'Synchronize Configuration'
,width: 300
,align: 't'
,closable: false
}); });
} else { console.error(response);
me.logout();
} }
}); });
// Firebase not empty and Have no Services
} else if ( snapshot2.hasChildren() && Ext.getStore('Services').getCount() === 0 ) {
importServices(snapshot2);
} else {
// Save the profile and JWT.
localStorage.setItem('profile', JSON.stringify(profile));
localStorage.setItem('id_token', authResult.idToken);
} }
,restoreConfiguration: function() {
var me = this;
Ext.cq1('app-main').getController().removeAllServices(false, function() {
me.lock.getProfile(localStorage.getItem('id_token'), function (err, profile) {
if (err) return alert('There was an error getting the profile: ' + err.message);
Ext.each(profile.user_metadata.services, function(s) {
var service = Ext.create('Rambox.model.Service', s);
service.save();
Ext.getStore('Services').add(service);
}); });
})['catch'](function(error) {
Ext.Msg.hide(); require('electron').remote.getCurrentWindow().reload();
Ext.Msg.show({
title: 'Firebase Error'
,message: error.message+'<br><br>Code: '+error.code+'<br><br>Sorry, try again later.'
,icon: Ext.Msg.ERROR
,buttons: Ext.Msg.OK
}); });
me.logout();
Ext.cq1('app-main').getViewModel().set('username', '');
Ext.cq1('app-main').getViewModel().set('avatar', '');
}); });
} }
});
Ext.cq1('app-main').getViewModel().set('username', profile.name); ,checkConfiguration: function() {
Ext.cq1('app-main').getViewModel().set('avatar', profile.picture); var me = this;
me.lock.getProfile(localStorage.getItem('id_token'), function (err, profile) {
if (err) return alert('There was an error getting the profile: ' + err.message);
if ( Math.floor(new Date(profile.user_metadata.services_lastupdate) / 1000) > Math.floor(new Date(Ext.decode(localStorage.getItem('profile')).user_metadata.services_lastupdate) / 1000) ) {
Ext.toast({
html: 'Your settings are out of date.'
,title: 'Synchronize Configuration'
,width: 300
,align: 't'
,closable: false
}); });
} else {
Ext.toast({
html: 'Latest backup is already applied.'
,title: 'Synchronize Configuration'
,width: 300
,align: 't'
,closable: false
});
}
}); });
} }
,login: function() { ,login: function() {
var me = this; var me = this;
if ( !me.auth0 ) Rambox.ux.Auth0.init();
me.lock.show(); me.lock.show();
} }

170
app/ux/Firebase.js

@ -1,170 +0,0 @@
Ext.define('Rambox.ux.Firebase', {
singleton: true
// private
,eventsDefined: false
,createEvents: function() {
//if ( this.eventsDefined || !localStorage.getItem('id_token') ) return;
if ( !localStorage.getItem('id_token') ) return;
console.log('Define listeners for Firebase');
var ref = fireRef.database().ref('users/' + Ext.decode(localStorage.getItem('profile')).user_id).child('services');
// Attach an asynchronous callback to read the data at our posts reference
ref.on("child_changed", function(snapshot, prevChildKey) {
// Disable duplicate actions when user edit a service
var rec = Ext.getStore('Services').findRecord('firebase_key', snapshot.key);
var recData = Ext.clone(rec.data);
delete recData.id;
delete recData.firebase_key;
if ( Ext.Object.equals(recData, snapshot.val()) ) return;
console.info('Firebase - Child Changed', snapshot.val(), snapshot.key, prevChildKey);
// Suspend events
Ext.getStore('Services').suspendEvent('update');
// Change the title of the Tab
Ext.getCmp('tab_'+rec.get('id')).setTitle(snapshot.val().name);
// Change sound of the Tab
Ext.getCmp('tab_'+rec.get('id')).setAudioMuted(snapshot.val().muted);
// Change notifications of the Tab
Ext.getCmp('tab_'+rec.get('id')).setNotifications(snapshot.val().notifications);
// Change the icon of the Tab
if ( rec.get('type') === 'custom' && rec.get('logo') !== snapshot.val().logo ) Ext.getCmp('tab_'+rec.get('id')).setConfig('icon', snapshot.val().logo === '' ? 'resources/icons/custom.png' : snapshot.val().logo);
// Change the URL of the Tab
if ( rec.get('url') !== snapshot.val().url ) Ext.getCmp('tab_'+rec.get('id')).setURL(snapshot.val().url);
// Change the align of the Tab
if ( rec.get('align') !== snapshot.val().align ) {
if ( rec.get('align') === 'left' ) {
Ext.cq1('app-main').moveBefore(Ext.getCmp('tab_'+rec.get('id')), Ext.getCmp('tbfill'));
} else {
Ext.cq1('app-main').moveAfter(Ext.getCmp('tab_'+rec.get('id')), Ext.getCmp('tbfill'));
}
}
// Apply the JS Code of the Tab
if ( rec.get('js_unread') !== snapshot.val().js_unread ) {
Ext.Msg.confirm('CUSTOM CODE', 'Rambox needs to reload the service to execute the new JavaScript code. Do you want to do it now?', function( btnId ) {
if ( btnId === 'yes' ) Ext.getCmp('tab_'+rec.get('id')).reloadService();
});
}
// Position
if ( rec.get('position') !== snapshot.val().position ) {
var pos = parseInt(snapshot.val().position);
if ( rec.get('align') === 'right' ) pos++;
Ext.cq1('app-main').move(Ext.getCmp('tab_'+rec.get('id')), pos);
}
rec.set(snapshot.val());
rec.save();
Ext.getCmp('tab_'+rec.get('id')).record = rec;
Ext.getCmp('tab_'+rec.get('id')).tabConfig.service = rec;
// Enable/Disable
if ( recData.enabled !== snapshot.val().enabled ) Ext.getCmp('tab_'+rec.get('id')).setEnabled(snapshot.val().enabled);
Ext.getStore('Services').resumeEvent('update');
Ext.getStore('Services').load();
}, function (errorObject) {
});
ref.on("child_added", function(snapshot, prevChildKey) {
console.info('Firebase - Child Added', snapshot.val(), snapshot.key, prevChildKey);
Ext.getStore('Services').suspendEvents(['add', 'update']);
var rec = Ext.getStore('Services').findRecord('firebase_key', snapshot.key);
// For all version of Rambox (0.3.0)
if ( rec === null ) rec = Ext.getStore('Services').getById(snapshot.val().id);
var data = snapshot.val();
// Update current services
if ( rec ) {
delete data.id;
data.firebase_key = snapshot.key;
rec.set(data);
rec.save();
} else { // Add new ones if exist
data.firebase_key = snapshot.key;
rec = Ext.create('Rambox.model.Service', data);
rec.save();
Ext.getStore('Services').add(rec);
var tabData = {
xtype: 'webview'
,id: 'tab_'+rec.get('id')
,title: rec.get('name')
,icon: rec.get('type') !== 'custom' ? 'resources/icons/'+rec.get('logo') : ( rec.get('logo') === '' ? 'resources/icons/custom.png' : rec.get('logo'))
,src: rec.get('url')
,type: rec.get('type')
,align: rec.get('align')
,notifications: rec.get('notifications')
,muted: rec.get('muted')
,record: rec
,tabConfig: {
service: rec
}
};
if ( rec.get('align') === 'left' ) {
var tbfill = Ext.cq1('app-main').getTabBar().down('tbfill');
Ext.cq1('app-main').insert(Ext.cq1('app-main').getTabBar().items.indexOf(tbfill), tabData);
} else {
Ext.cq1('app-main').add(tabData);
}
}
Ext.getStore('Services').resumeEvents(['add', 'update']);
Ext.getStore('Services').load();
//rec.commit();
}, function (errorObject) {
});
ref.on("child_removed", function(snapshot) {
console.info('Firebase - Child Removed', snapshot.val(), snapshot.key);
var rec = Ext.getStore('Services').findRecord('firebase_key', snapshot.key);
// Remove record from localStorage
if ( rec ) {
Ext.getStore('Services').suspendEvent('remove');
Ext.getStore('Services').remove(rec);
Ext.cq1('app-main').suspendEvent('remove');
Ext.getCmp('tab_'+rec.get('id')).close();
Ext.cq1('app-main').resumeEvent('remove');
Ext.getStore('Services').resumeEvent('remove');
Ext.getStore('Services').load();
}
}, function (errorObject) {
});
this.eventsDefined = true;
}
,removeEvents: function() {
//if ( !this.eventsDefined ) return;
console.log('Remove listeners for Firebase');
var ref = fireRef.database().ref('users/' + Ext.decode(localStorage.getItem('profile')).user_id).child('services');
ref.off('child_changed', function() {
console.warn('Firebase - Child Changed event removed');
});
ref.off('child_added', function() {
console.warn('Firebase - Child Added event removed');
});
ref.off('child_removed', function() {
console.warn('Firebase - Child Removed event removed');
});
}
});

31
app/view/main/Main.js

@ -263,6 +263,37 @@ Ext.define('Rambox.view.main.Main', {
} }
,menu: [ ,menu: [
{ {
text: 'Synchronize Configuration'
,glyph: 'xf0c2@FontAwesome'
,menu: [
{
xtype: 'label'
,bind: {
html: '<b class="menu-title">Last Sync: {last_sync}</b>'
}
}
,{
text: 'Backup'
,glyph: 'xf0ee@FontAwesome'
,scope: Rambox.ux.Auth0
,handler: Rambox.ux.Auth0.backupConfiguration
}
,{
text: 'Restore'
,glyph: 'xf0ed@FontAwesome'
,scope: Rambox.ux.Auth0
,handler: Rambox.ux.Auth0.restoreConfiguration
}
,{
text: 'Check for updated backup'
,glyph: 'xf021@FontAwesome'
,scope: Rambox.ux.Auth0
,handler: Rambox.ux.Auth0.checkConfiguration
}
]
}
,'-'
,{
text: 'Logout' text: 'Logout'
,glyph: 'xf08b@FontAwesome' ,glyph: 'xf08b@FontAwesome'
,handler: 'logout' ,handler: 'logout'

7
app/view/main/MainController.js

@ -352,10 +352,6 @@ Ext.define('Rambox.view.main.MainController', {
// Google Analytics Event // Google Analytics Event
ga_storage._trackEvent('Users', 'loggedOut'); ga_storage._trackEvent('Users', 'loggedOut');
firebase.auth().signOut().then(function() {
// Remove Events for Firebase
Rambox.ux.Firebase.removeEvents();
// Logout from Auth0 // Logout from Auth0
Rambox.ux.Auth0.logout(); Rambox.ux.Auth0.logout();
@ -365,9 +361,6 @@ Ext.define('Rambox.view.main.MainController', {
if ( Ext.isFunction(callback) ) callback(); if ( Ext.isFunction(callback) ) callback();
Ext.Msg.hide(); Ext.Msg.hide();
}, function(error) {
console.error(error);
});
} }
if ( btn ) { if ( btn ) {

1
app/view/main/MainModel.js

@ -8,5 +8,6 @@ Ext.define('Rambox.view.main.MainModel', {
name: 'Rambox' name: 'Rambox'
,username: localStorage.getItem('profile') ? JSON.parse(localStorage.getItem('profile')).name : '' ,username: localStorage.getItem('profile') ? JSON.parse(localStorage.getItem('profile')).name : ''
,avatar: localStorage.getItem('profile') ? JSON.parse(localStorage.getItem('profile')).picture : '' ,avatar: localStorage.getItem('profile') ? JSON.parse(localStorage.getItem('profile')).picture : ''
,last_sync: localStorage.getItem('profile') ? new Date(JSON.parse(localStorage.getItem('profile')).user_metadata.services_lastupdate).toUTCString() : ''
} }
}); });

6
electron/menu.js

@ -268,14 +268,8 @@ 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);
if ( process.platform === 'win32' ) {
electron.autoUpdater.checkForUpdates();
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'); send('autoUpdater:check-update');
} }
}
}); });
helpSubmenu.push({ helpSubmenu.push({
label: `&About ${appName}`, label: `&About ${appName}`,

2
electron/updater.js

@ -12,7 +12,7 @@ const initialize = (window) => {
ipcMain.on('autoUpdater:check-for-updates', (event) => autoUpdater.checkForUpdates()); ipcMain.on('autoUpdater:check-for-updates', (event) => autoUpdater.checkForUpdates());
webContents.on('did-finish-load', () => { webContents.on('did-finish-load', () => {
autoUpdater.setFeedURL(url); autoUpdater.setFeedURL(url);
autoUpdater.checkForUpdates(); //autoUpdater.checkForUpdates();
}); });
}; };

3
package.json

@ -95,9 +95,6 @@
}, },
"dependencies": { "dependencies": {
"auto-launch": "4.0.0", "auto-launch": "4.0.0",
"firebase": "^3.0.5",
"electron-spell-check-provider": "^1.0.0",
"firebase-token-generator": "^2.0.0",
"tmp": "0.0.28", "tmp": "0.0.28",
"mime": "^1.3.4", "mime": "^1.3.4",
"electron-is-dev": "^0.1.1", "electron-is-dev": "^0.1.1",

Loading…
Cancel
Save