Browse Source

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
v0.5.8
Ramiro Saenz 8 years ago
parent
commit
286a8bf107
  1. 3
      app/store/Services.js
  2. 2
      app/view/main/Main.js
  3. 23
      app/view/main/MainController.js

3
app/store/Services.js

@ -39,6 +39,9 @@ Ext.define('Rambox.store.Services', {
break; break;
} }
// If the service is disabled, we dont add it to tab bar
if ( !service.get('enabled') ) return;
var cfg = { var cfg = {
xtype: 'webview' xtype: 'webview'
,id: 'tab_'+service.get('id') ,id: 'tab_'+service.get('id')

2
app/view/main/Main.js

@ -144,7 +144,7 @@ Ext.define('Rambox.view.main.Main', {
xtype: 'templatecolumn' xtype: 'templatecolumn'
,width: 50 ,width: 50
,variableRowHeight: true ,variableRowHeight: true
,tpl: '<img src="{[ values.type !== \"custom\" ? \"resources/icons/\"+values.logo : (values.logo == \"\" ? \"resources/icons/custom.png\" : values.logo) ]}" data-qtip="{type:capitalize}" width="32" />' ,tpl: '<img src="{[ values.type !== \"custom\" ? \"resources/icons/\"+values.logo : (values.logo == \"\" ? \"resources/icons/custom.png\" : values.logo) ]}" data-qtip="{type:capitalize}" width="32" style="{[ values.enabled ? \"-webkit-filter: grayscale(0)\" : \"-webkit-filter: grayscale(1)\" ]}" />'
} }
,{ ,{
dataIndex: 'name' dataIndex: 'name'

23
app/view/main/MainController.js

@ -24,7 +24,7 @@ Ext.define('Rambox.view.main.MainController', {
var store = Ext.getStore('Services'); var store = Ext.getStore('Services');
store.suspendEvent('remove'); store.suspendEvent('remove');
Ext.each(tabPanel.items.items, function(t, i) { 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')); var rec = store.getById(t.record.get('id'));
if ( rec.get('align') === 'right' ) i--; if ( rec.get('align') === 'right' ) i--;
rec.set('position', i); rec.set('position', i);
@ -54,7 +54,26 @@ Ext.define('Rambox.view.main.MainController', {
,onEnableDisableService: function(cc, rowIndex, checked) { ,onEnableDisableService: function(cc, rowIndex, checked) {
var rec = Ext.getStore('Services').getAt(rowIndex); 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 ) { ,onNewServiceSelect: function( view, record, item, index, e ) {

Loading…
Cancel
Save