Browse Source

Added wizard to fix sync bug

pull/884/head
Ramiro Saenz 8 years ago
parent
commit
d4038a3e8d
  1. 70
      app/Application.js
  2. 10
      app/ux/Auth0.js

70
app/Application.js

@ -204,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();
}

10
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;
@ -60,7 +61,7 @@ Ext.define('Rambox.ux.Auth0', {
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();
@ -77,7 +78,7 @@ Ext.define('Rambox.ux.Auth0', {
});
}
,backupConfiguration: function() {
,backupConfiguration: function(callback) {
var me = this;
Ext.Msg.wait('Saving backup...', 'Please wait...');
@ -113,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);
@ -125,6 +128,9 @@ Ext.define('Rambox.ux.Auth0', {
,align: 't'
,closable: false
});
if ( Ext.isFunction(callback) ) callback.bind(me)();
console.error(response);
}
});

Loading…
Cancel
Save