Browse Source

v0.5.9

0.5.9
pull/865/merge 0.5.9
Ramiro Saenz 8 years ago committed by GitHub
parent
commit
3674116d50
  1. 3
      app.js
  2. 1
      app.json
  3. 78
      app/Application.js
  4. 5
      app/package.json
  5. 3
      app/store/ServicesList.js
  6. 16
      app/ux/Auth0.js
  7. 9
      app/ux/WebView.js
  8. 2
      appveyor.yml
  9. 21
      electron/main.js
  10. 3
      package.json

3
app.js

@ -1,4 +1,7 @@
var auth0, lock; // Auth0 vars
// Enable Cookies
var ElectronCookies = require('@exponent/electron-cookies');
ElectronCookies.enable({ origin: 'http://rambox.pro' });
// Sencha App
Ext.setGlyphFontFamily('FontAwesome');

1
app.json

@ -40,6 +40,7 @@
* ]
*/
"requires": [
"ext-locale"
],
/**

78
app/Application.js

@ -7,6 +7,7 @@ Ext.define('Rambox.Application', {
'Rambox.ux.Auth0'
,'Rambox.util.MD5'
,'Ext.window.Toast'
,'Ext.util.Cookies'
]
,stores: [
@ -30,9 +31,16 @@ Ext.define('Rambox.Application', {
ga_storage._trackPageview('/index.html', 'main');
ga_storage._trackEvent('Versions', require('electron').remote.app.getVersion());
// Load language for Ext JS library
Ext.Loader.loadScript({url: Ext.util.Format.format("ext/packages/ext-locale/build/ext-locale-{0}.js", localStorage.getItem('locale-auth0') || 'en')});
// Initialize Auth0
Rambox.ux.Auth0.init();
// Set cookies to help Tooltip.io messages segmentation
Ext.util.Cookies.set('version', require('electron').remote.app.getVersion());
if ( Ext.util.Cookies.get('auth0') === null ) Ext.util.Cookies.set('auth0', false);
// Check for updates
if ( require('electron').remote.process.argv.indexOf('--without-update') === -1 && process.platform !== 'win32' ) Rambox.app.checkUpdate(true);
@ -196,6 +204,76 @@ Ext.define('Rambox.Application', {
Ext.cq1('app-main').getController().showLockWindow();
}
// Synchronization problem in version 0.5.3 steps to fix it
if ( localStorage.getItem('id_token') && localStorage.getItem('refresh_token') === null ) {
var win = Ext.create('Ext.window.Window', {
title: 'Backup your services'
,autoShow: true
,modal: true
,closable: false
,resizable: false
,bodyPadding: '0 15 15 15'
,width: 500
,layout: 'card'
,items: [
{
xtype: 'container'
,html: '<h1>Synchronization problem fixed!</h1>In previous version, we had a bug that backing up your services throw an error. Now is fixed, but you will need to follow two simple steps to make it work.<br><br>If you decide not to do it now, you can cancel but it will ask you again next time you open Rambox until you do it.'
}
,{
xtype: 'container'
,html: '<h1>Login again</h1>Just click the "Sign in" button at the bottom-right of this window to sign in again with the same account you used before.'
}
,{
xtype: 'container'
,html: '<h1>Backup</h1>To finish, click the "Sync!" button to backup your current services and that\'s all!'
}
]
,buttons: [
{
text: locale['button[1]']
,ui: 'decline'
,handler: function() {
win.close();
}
}
,'->'
,{
text: 'Start'
,handler: function(btn) {
btn.hide();
btn.nextSibling('#signin').show();
win.getLayout().setActiveItem(1);
}
}
,{
text: 'Sign in'
,itemId: 'signin'
,hidden: true
,handler: function(btn) {
Rambox.ux.Auth0.backupCurrent = true;
Rambox.ux.Auth0.login();
Ext.defer(Rambox.ux.Auth0.logout, 1000);
btn.hide();
btn.nextSibling('#sync').show();
win.getLayout().setActiveItem(2);
}
}
,{
text: 'Sync!'
,itemId: 'sync'
,hidden: true
,handler: function() {
Rambox.ux.Auth0.backupConfiguration(function() {
win.close();
Rambox.ux.Auth0.backupCurrent = false;
});
}
}
]
});
}
// Remove spinner
Ext.get('spinner').destroy();
}

5
app/package.json

@ -1,7 +1,7 @@
{
"name": "Rambox",
"productName": "Rambox",
"version": "0.5.8",
"version": "0.5.9",
"description": "Rambox",
"main": "electron/main.js",
"private": true,
@ -33,6 +33,7 @@
"tmp": "0.0.28",
"mime": "^1.3.4",
"electron-is-dev": "^0.1.1",
"electron-config": "0.2.1"
"electron-config": "0.2.1",
"@exponent/electron-cookies": "2.0.0"
}
}

3
app/store/ServicesList.js

@ -116,8 +116,9 @@ Ext.define('Rambox.store.ServicesList', {
,url: 'https://mail.google.com/mail/'
,type: 'email'
,allow_popups: true
,js_unread: 'Object.defineProperty(document,"title",{configurable:!0,set:function(a){var b=document.getElementsByClassName("aim")[0];t=0,b.textContent.indexOf("(")!=-1&&(t=parseInt(b.textContent.replace(/[^0-9]/g,""))),document.getElementsByTagName("title")[0].innerHTML="("+t+") Gmail"},get:function(){return document.getElementsByTagName("title")[0].innerHTML}});'
,js_unread: 'function checkUnread(){var a=document.getElementsByClassName("aim")[0];updateBadge(-1!=a.textContent.indexOf("(")&&(t=parseInt(a.textContent.replace(/[^0-9]/g,""))))}function updateBadge(a){a>=1?rambox.setUnreadCount(a):rambox.clearUnreadCount()}setInterval(checkUnread,3e3);'
,note: 'To enable desktop notifications, you have to go to Settings inside Gmail. <a href="https://support.google.com/mail/answer/1075549?ref_topic=3394466" target="_blank">Read more...</a>'
,dont_update_unread_from_title: true
},
{
id: 'inbox'

16
app/ux/Auth0.js

@ -4,6 +4,7 @@ Ext.define('Rambox.ux.Auth0', {
// private
,lock: null
,auth0: null
,backupCurrent: false
,init: function() {
var me = this;
@ -51,13 +52,16 @@ Ext.define('Rambox.ux.Auth0', {
// Google Analytics Event
ga_storage._trackEvent('Users', 'loggedIn');
// Set cookies to help Tooltip.io messages segmentation
Ext.util.Cookies.set('auth0', true);
// User is logged in
// Save the profile and JWT.
localStorage.setItem('profile', JSON.stringify(profile));
localStorage.setItem('id_token', authResult.idToken);
localStorage.setItem('refresh_token', authResult.refreshToken);
if ( !Ext.isEmpty(profile.user_metadata) && !Ext.isEmpty(profile.user_metadata.services) ) {
if ( !Ext.isEmpty(profile.user_metadata) && !Ext.isEmpty(profile.user_metadata.services) && !me.backupCurrent ) {
Ext.each(profile.user_metadata.services, function(s) {
var service = Ext.create('Rambox.model.Service', s);
service.save();
@ -74,7 +78,7 @@ Ext.define('Rambox.ux.Auth0', {
});
}
,backupConfiguration: function() {
,backupConfiguration: function(callback) {
var me = this;
Ext.Msg.wait('Saving backup...', 'Please wait...');
@ -110,6 +114,8 @@ Ext.define('Rambox.ux.Auth0', {
,align: 't'
,closable: false
});
if ( Ext.isFunction(callback) ) callback.bind(me)();
}
,failure: function(response) {
if ( response.status === 401 ) return me.renewToken(me.backupConfiguration);
@ -122,6 +128,9 @@ Ext.define('Rambox.ux.Auth0', {
,align: 't'
,closable: false
});
if ( Ext.isFunction(callback) ) callback.bind(me)();
console.error(response);
}
});
@ -225,5 +234,8 @@ Ext.define('Rambox.ux.Auth0', {
localStorage.removeItem('profile');
localStorage.removeItem('id_token');
localStorage.removeItem('refresh_token');
// Set cookies to help Tooltip.io messages segmentation
Ext.util.Cookies.set('auth0', false);
}
});

9
app/ux/WebView.js

@ -347,6 +347,7 @@ Ext.define('Rambox.ux.WebView',{
// Mute Webview
if ( me.record.get('muted') || localStorage.getItem('locked') || JSON.parse(localStorage.getItem('dontDisturb')) ) me.setAudioMuted(true, true);
var js_inject = '';
// Injected code to detect new messages
if ( me.record ) {
var js_unread = Ext.getStore('ServicesList').getById(me.record.get('type')).get('js_unread');
@ -355,7 +356,7 @@ Ext.define('Rambox.ux.WebView',{
console.groupCollapsed(me.record.get('type').toUpperCase() + ' - JS Injected to Detect New Messages');
console.info(me.type);
console.log(js_unread);
webview.executeJavaScript(js_unread);
js_inject += js_unread;
}
}
@ -363,13 +364,13 @@ Ext.define('Rambox.ux.WebView',{
if ( Ext.getStore('ServicesList').getById(me.record.get('type')).get('titleBlink') ) {
var js_preventBlink = 'var originalTitle=document.title;Object.defineProperty(document,"title",{configurable:!0,set:function(a){null===a.match(new RegExp("[(]([0-9•]+)[)][ ](.*)","g"))&&a!==originalTitle||(document.getElementsByTagName("title")[0].innerHTML=a)},get:function(){return document.getElementsByTagName("title")[0].innerHTML}});';
console.log(js_preventBlink);
webview.executeJavaScript(js_preventBlink);
js_inject += js_preventBlink;
}
console.groupEnd();
// Scroll always to top (bug)
webview.executeJavaScript('document.body.scrollTop=0;');
js_inject += 'document.body.scrollTop=0;';
// Handles Certificate Errors
webview.getWebContents().on('certificate-error', function(event, url, error, certificate, callback) {
@ -387,6 +388,8 @@ Ext.define('Rambox.ux.WebView',{
});
me.down('statusbar').down('button').show();
});
webview.executeJavaScript(js_inject);
});
webview.addEventListener('ipc-message', function(event) {

2
appveyor.yml

@ -1,4 +1,4 @@
version: 0.5.8
version: 0.5.9
pull_requests:
do_not_increment_build_number: true
branches:

21
electron/main.js

@ -136,6 +136,7 @@ function createWindow () {
,autoHideMenuBar: config.get('hide_menu_bar')
,skipTaskbar: config.get('window_display_behavior') === 'show_trayIcon'
,show: !config.get('start_minimized')
,acceptFirstMouse: true
,webPreferences: {
webSecurity: false
,nodeIntegration: true
@ -162,11 +163,23 @@ function createWindow () {
// Open links in default browser
mainWindow.webContents.on('new-window', function(e, url, frameName, disposition, options) {
if ( disposition !== 'foreground-tab' ) return;
const protocol = require('url').parse(url).protocol;
if (protocol === 'http:' || protocol === 'https:' || protocol === 'mailto:') {
e.preventDefault();
shell.openExternal(url);
switch ( disposition ) {
case 'new-window':
e.preventDefault();
const win = new BrowserWindow(options);
win.once('ready-to-show', () => win.show());
win.loadURL(url);
e.newGuest = win;
break;
case 'foreground-tab':
if (protocol === 'http:' || protocol === 'https:' || protocol === 'mailto:') {
e.preventDefault();
shell.openExternal(url);
}
break;
default:
break;
}
});

3
package.json

@ -104,6 +104,7 @@
"tmp": "0.0.28",
"mime": "^1.3.4",
"electron-is-dev": "^0.1.1",
"electron-config": "0.2.1"
"electron-config": "0.2.1",
"@exponent/electron-cookies": "2.0.0"
}
}

Loading…
Cancel
Save