From 6fd77c45e89e201c9b28cc3f38845442e5f267bd Mon Sep 17 00:00:00 2001 From: Juan Manuel Gonzalez Alama Date: Tue, 28 May 2019 16:52:59 -0300 Subject: [PATCH] Disable "Remove All" if there are no services Fixes #2264 --- app/store/Services.js | 6 +++++- app/view/main/Main.js | 3 +++ app/view/main/MainController.js | 6 +++--- app/view/main/MainModel.js | 1 + 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/store/Services.js b/app/store/Services.js index 5b2b2b7b..20fe85bd 100644 --- a/app/store/Services.js +++ b/app/store/Services.js @@ -21,7 +21,7 @@ Ext.define('Rambox.store.Services', { ] ,listeners: { - load: function( store, records, successful ) { + load: function( store, records, successful ) { Ext.cq1('app-main').suspendEvent('add'); var servicesLeft = []; @@ -76,5 +76,9 @@ Ext.define('Rambox.store.Services', { store.suspendEvent('load'); Ext.cq1('app-main').resumeEvent('add'); } + ,datachanged: function(store, eOpts) { + var isEmpty = store.getCount() > 0 ? false : true; + Ext.cq1('app-main').getViewModel().set('emptyServices', isEmpty); + } } }); diff --git a/app/view/main/Main.js b/app/view/main/Main.js index e3b3a04b..d5c558df 100644 --- a/app/view/main/Main.js +++ b/app/view/main/Main.js @@ -148,6 +148,9 @@ Ext.define('Rambox.view.main.Main', { ,baseCls: '' ,tooltip: locale['app.main[10]'] ,handler: 'removeAllServices' + ,bind: { + disabled: '{emptyServices}' + } } ] ,columns: [ diff --git a/app/view/main/MainController.js b/app/view/main/MainController.js index 015656ca..c36ed859 100644 --- a/app/view/main/MainController.js +++ b/app/view/main/MainController.js @@ -192,12 +192,12 @@ Ext.define('Rambox.view.main.MainController', { ,removeAllServices: function(btn, callback) { var me = this; - // Clear counter for unread messaging - document.title = 'Rambox'; - if ( btn ) { Ext.Msg.confirm(locale['app.window[12]'], locale['app.window[14]'], function(btnId) { if ( btnId === 'yes' ) { + // Clear counter for unread messaging + document.title = 'Rambox'; + Ext.cq1('app-main').suspendEvent('remove'); Ext.getStore('Services').load(); Ext.Msg.wait('Please wait until we clear all.', 'Removing...'); diff --git a/app/view/main/MainModel.js b/app/view/main/MainModel.js index 32350ee6..ff783602 100644 --- a/app/view/main/MainModel.js +++ b/app/view/main/MainModel.js @@ -9,5 +9,6 @@ Ext.define('Rambox.view.main.MainModel', { ,username: localStorage.getItem('profile') ? JSON.parse(localStorage.getItem('profile')).name : '' ,avatar: localStorage.getItem('profile') ? JSON.parse(localStorage.getItem('profile')).picture : '' ,last_sync: localStorage.getItem('profile') && JSON.parse(localStorage.getItem('profile')).user_metadata && JSON.parse(localStorage.getItem('profile')).user_metadata.services_lastupdate ? new Date(JSON.parse(localStorage.getItem('profile')).user_metadata.services_lastupdate).toUTCString() : '' + ,emptyServices: true } });