Browse Source

Feature to set default service to display

Fixes #957
Fixes #1132
pull/1193/head
Ramiro Saenz 8 years ago
parent
commit
0666771b92
  1. 26
      app/store/Services.js
  2. 5
      app/view/main/MainController.js
  3. 26
      app/view/preferences/Preferences.js
  4. 1
      electron/main.js

26
app/store/Services.js

@ -26,19 +26,6 @@ Ext.define('Rambox.store.Services', {
var servicesLeft = []; var servicesLeft = [];
var servicesRight = []; var servicesRight = [];
store.each(function(service) { store.each(function(service) {
// Fix some services with bad IDs
// TODO: Remove in next release
switch ( service.get('type') ) {
case 'office365':
service.set('type', 'outlook365');
break;
case ' irccloud':
service.set('type', 'irccloud');
break;
default:
break;
}
// If the service is disabled, we dont add it to tab bar // If the service is disabled, we dont add it to tab bar
if ( !service.get('enabled') ) return; if ( !service.get('enabled') ) return;
@ -65,6 +52,19 @@ Ext.define('Rambox.store.Services', {
if ( !Ext.isEmpty(servicesLeft) ) Ext.cq1('app-main').insert(1, servicesLeft); if ( !Ext.isEmpty(servicesLeft) ) Ext.cq1('app-main').insert(1, servicesLeft);
if ( !Ext.isEmpty(servicesRight) ) Ext.cq1('app-main').add(servicesRight); if ( !Ext.isEmpty(servicesRight) ) Ext.cq1('app-main').add(servicesRight);
// Set default active service
const config = ipc.sendSync('getConfig');
switch ( config.default_service ) {
case 'last':
Ext.cq1('app-main').setActiveTab(localStorage.getItem('last_active_service'));
break;
case 'ramboxTab':
break;
default:
if ( Ext.getCmp('tab_'+config.default_service) ) Ext.cq1('app-main').setActiveTab('tab_'+config.default_service);
break;
}
store.suspendEvent('load'); store.suspendEvent('load');
Ext.cq1('app-main').resumeEvent('add'); Ext.cq1('app-main').resumeEvent('add');
} }

5
app/view/main/MainController.js

@ -10,6 +10,8 @@ Ext.define('Rambox.view.main.MainController', {
// Set Google Analytics event // Set Google Analytics event
ga_storage._trackPageview('/index.html', 'main'); ga_storage._trackPageview('/index.html', 'main');
localStorage.setItem('last_active_service', newTab.id);
if ( newTab.id === 'ramboxTab' ) { if ( newTab.id === 'ramboxTab' ) {
if ( Rambox.app.getTotalNotifications() > 0 ) { if ( Rambox.app.getTotalNotifications() > 0 ) {
document.title = 'Rambox ('+ Rambox.app.getTotalNotifications() +')'; document.title = 'Rambox ('+ Rambox.app.getTotalNotifications() +')';
@ -129,6 +131,9 @@ Ext.define('Rambox.view.main.MainController', {
clearData(webview, tab); clearData(webview, tab);
} }
const config = ipc.sendSync('getConfig');
if ( config.default_service === rec.get('id') ) ipc.send('setConfig', Ext.apply(config, { default_service: 'ramboxTab' }));
function clearData(webview, tab) { function clearData(webview, tab) {
webview.getWebContents().clearHistory(); webview.getWebContents().clearHistory();
webview.getWebContents().session.flushStorageData(); webview.getWebContents().session.flushStorageData();

26
app/view/preferences/Preferences.js

@ -38,6 +38,16 @@ Ext.define('Rambox.view.preferences.Preferences',{
,initComponent: function() { ,initComponent: function() {
var config = ipc.sendSync('getConfig'); var config = ipc.sendSync('getConfig');
var defaultServiceOptions = [];
defaultServiceOptions.push({ value: 'ramboxTab', label: 'Rambox Tab' });
defaultServiceOptions.push({ value: 'last', label: 'Last Active Service' });
Ext.getStore('Services').each(function(rec) {
defaultServiceOptions.push({
value: rec.get('id')
,label: rec.get('name')
});
});
this.items = [ this.items = [
{ {
xtype: 'form' xtype: 'form'
@ -114,6 +124,22 @@ Ext.define('Rambox.view.preferences.Preferences',{
,value: config.hide_menu_bar ,value: config.hide_menu_bar
,hidden: process.platform !== 'win32' ,hidden: process.platform !== 'win32'
} }
,{
xtype: 'combo'
,name: 'default_service'
,fieldLabel: 'Default service to display when Rambox starts'
,labelAlign: 'top'
//,width: 380
//,labelWidth: 105
,value: config.default_service
,displayField: 'label'
,valueField: 'value'
,editable: false
,store: Ext.create('Ext.data.Store', {
fields: ['value', 'label']
,data: defaultServiceOptions
})
}
,{ ,{
xtype: 'combo' xtype: 'combo'
,name: 'window_display_behavior' ,name: 'window_display_behavior'

1
electron/main.js

@ -34,6 +34,7 @@ const config = new Config({
,proxyPort: '' ,proxyPort: ''
,locale: 'en' ,locale: 'en'
,enable_hidpi_support: false ,enable_hidpi_support: false
,default_service: 'ramboxTab'
,x: undefined ,x: undefined
,y: undefined ,y: undefined

Loading…
Cancel
Save