From 286a8bf1076a7228e7721f2f8a2a38d283e44c61 Mon Sep 17 00:00:00 2001 From: Ramiro Saenz Date: Tue, 9 May 2017 19:00:07 -0300 Subject: [PATCH] Hide disabled services from Tabbar Disabled services will not be rendered, so it will not shown tab in tabbar and also not consume RAM. Fixes #667 --- app/store/Services.js | 3 +++ app/view/main/Main.js | 2 +- app/view/main/MainController.js | 23 +++++++++++++++++++++-- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/app/store/Services.js b/app/store/Services.js index cb38447f..134efc34 100644 --- a/app/store/Services.js +++ b/app/store/Services.js @@ -39,6 +39,9 @@ Ext.define('Rambox.store.Services', { break; } + // If the service is disabled, we dont add it to tab bar + if ( !service.get('enabled') ) return; + var cfg = { xtype: 'webview' ,id: 'tab_'+service.get('id') diff --git a/app/view/main/Main.js b/app/view/main/Main.js index 1a23ad68..3a18be6a 100644 --- a/app/view/main/Main.js +++ b/app/view/main/Main.js @@ -144,7 +144,7 @@ Ext.define('Rambox.view.main.Main', { xtype: 'templatecolumn' ,width: 50 ,variableRowHeight: true - ,tpl: '' + ,tpl: '' } ,{ dataIndex: 'name' diff --git a/app/view/main/MainController.js b/app/view/main/MainController.js index 024a9067..c3d6989e 100644 --- a/app/view/main/MainController.js +++ b/app/view/main/MainController.js @@ -24,7 +24,7 @@ Ext.define('Rambox.view.main.MainController', { var store = Ext.getStore('Services'); store.suspendEvent('remove'); Ext.each(tabPanel.items.items, function(t, i) { - if ( t.id !== 'ramboxTab' && t.id !== 'tbfill' ) { + if ( t.id !== 'ramboxTab' && t.id !== 'tbfill' && t.record.get('enabled') ) { var rec = store.getById(t.record.get('id')); if ( rec.get('align') === 'right' ) i--; rec.set('position', i); @@ -54,7 +54,26 @@ Ext.define('Rambox.view.main.MainController', { ,onEnableDisableService: function(cc, rowIndex, checked) { var rec = Ext.getStore('Services').getAt(rowIndex); - Ext.getCmp('tab_'+rec.get('id')).setEnabled(checked); + if ( !checked ) { + Ext.getCmp('tab_'+rec.get('id')).destroy(); + } else { + Ext.cq1('app-main').insert(rec.get('align') === 'left' ? rec.get('position') : rec.get('position')+1, { + 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') + ,muted: rec.get('muted') + ,includeInGlobalUnreadCounter: rec.get('includeInGlobalUnreadCounter') + ,displayTabUnreadCounter: rec.get('displayTabUnreadCounter') + ,enabled: rec.get('enabled') + ,record: rec + ,tabConfig: { + service: rec + } + }); + } } ,onNewServiceSelect: function( view, record, item, index, e ) {