From 4beeb389e60d92efb0e02d6ba2a8bd0364cad8b7 Mon Sep 17 00:00:00 2001 From: Ramiro Saenz Date: Tue, 12 Jul 2016 17:21:53 -0300 Subject: [PATCH] New Version notification Check if there is a new version and notify the user. --- app/Application.js | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/app/Application.js b/app/Application.js index 69952b71..77fef7da 100644 --- a/app/Application.js +++ b/app/Application.js @@ -103,6 +103,45 @@ Ext.define('Rambox.Application', { ] }); + fireRef.database().ref('config').on('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); + var newVersionTB = Ext.cq1('app-main').addDocked({ + xtype: 'toolbar' + ,dock: 'top' + ,ui: 'newversion' + ,items: [ + '->' + ,{ + xtype: 'label' + ,html: 'New version is available! ('+snapshot.val().latestVersion+')' + } + ,{ + xtype: 'button' + ,text: 'Download' + ,href: 'https://getrambox.herokuapp.com/download' + } + ,{ + 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.') + }); + // Remove spinner Ext.get('spinner').destroy(); }