Browse Source

Fixed audio and notifications edition for services

Fixed #56
pull/116/head
Ramiro Saenz 9 years ago
parent
commit
6c9c55f613
  1. 24
      app/ux/WebView.js
  2. 14
      app/view/main/MainController.js

24
app/ux/WebView.js

@ -122,7 +122,11 @@ Ext.define('Rambox.ux.WebView',{
webview.addEventListener("dom-ready", function(e) { webview.addEventListener("dom-ready", function(e) {
// Mute Webview // Mute Webview
if ( !webview.isAudioMuted() && me.muted ) webview.setAudioMuted(me.muted); if ( me.muted ) me.setAudioMuted(me.muted);
// Notifications in Webview
webview.executeJavaScript('var originalNotification = Notification;');
if ( me.notifications ) me.setNotifications(me.notifications);
// Injected code to detect new messages // Injected code to detect new messages
if ( me.record && me.record.get('js_unread') !== '' ) { if ( me.record && me.record.get('js_unread') !== '' ) {
@ -184,4 +188,22 @@ Ext.define('Rambox.ux.WebView',{
webview.isDevToolsOpened() ? webview.closeDevTools() : webview.openDevTools(); webview.isDevToolsOpened() ? webview.closeDevTools() : webview.openDevTools();
} }
,setAudioMuted: function(muted) {
var me = this;
var webview = me.down('component').el.dom;
webview.setAudioMuted(muted);
}
,setNotifications: function(notification) {
var me = this;
var webview = me.down('component').el.dom;
if ( !notification ) {
webview.executeJavaScript('(function() { Notification = function() { } })();');
} else {
webview.executeJavaScript('(function() { Notification = originalNotification })();');
}
}
}); });

14
app/view/main/MainController.js

@ -135,6 +135,10 @@ Ext.define('Rambox.view.main.MainController', {
}); });
// Change the title of the Tab // Change the title of the Tab
Ext.getCmp('tab_'+record.get('id')).setTitle(formValues.serviceName); Ext.getCmp('tab_'+record.get('id')).setTitle(formValues.serviceName);
// Change sound of the Tab
Ext.getCmp('tab_'+record.get('id')).setAudioMuted(formValues.muted);
// Change notifications of the Tab
Ext.getCmp('tab_'+record.get('id')).setNotifications(formValues.notifications);
// Change the align of the Tab // Change the align of the Tab
if ( oldData.align !== formValues.align ) { if ( oldData.align !== formValues.align ) {
if ( formValues.align === 'left' ) { if ( formValues.align === 'left' ) {
@ -316,6 +320,10 @@ Ext.define('Rambox.view.main.MainController', {
}); });
// Change the title of the Tab // Change the title of the Tab
Ext.getCmp('tab_'+record.get('id')).setTitle(formValues.serviceName); Ext.getCmp('tab_'+record.get('id')).setTitle(formValues.serviceName);
// Change sound of the Tab
Ext.getCmp('tab_'+record.get('id')).setAudioMuted(formValues.muted);
// Change notifications of the Tab
Ext.getCmp('tab_'+record.get('id')).setNotifications(formValues.notifications);
// Change the align of the Tab // Change the align of the Tab
if ( oldData.align !== formValues.align ) { if ( oldData.align !== formValues.align ) {
if ( formValues.align === 'left' ) { if ( formValues.align === 'left' ) {
@ -590,6 +598,10 @@ Ext.define('Rambox.view.main.MainController', {
// Change the title of the Tab // Change the title of the Tab
Ext.getCmp('tab_'+record.get('id')).setTitle(formValues.serviceName); Ext.getCmp('tab_'+record.get('id')).setTitle(formValues.serviceName);
// Change sound of the Tab
Ext.getCmp('tab_'+record.get('id')).setAudioMuted(formValues.muted);
// Change notifications of the Tab
Ext.getCmp('tab_'+record.get('id')).setNotifications(formValues.notifications);
// Change the icon of the Tab // Change the icon of the Tab
Ext.getCmp('tab_'+record.get('id')).setIcon(record.get('logo') === '' ? 'resources/icons/custom.png' : record.get('logo')); Ext.getCmp('tab_'+record.get('id')).setIcon(record.get('logo') === '' ? 'resources/icons/custom.png' : record.get('logo'));
// Change the align of the Tab // Change the align of the Tab
@ -717,7 +729,7 @@ Ext.define('Rambox.view.main.MainController', {
var tab = Ext.getCmp('tab_'+serviceId); var tab = Ext.getCmp('tab_'+serviceId);
// Mute sounds // Mute sounds
tab.down('component').el.dom.getWebContents().setAudioMuted(btn.pressed); tab.setAudioMuted(btn.pressed);
// Prevent Notifications // Prevent Notifications
if ( btn.pressed ) { if ( btn.pressed ) {

Loading…
Cancel
Save