From 6c9c55f6134e822414ae15e9dc807581f9db4ca7 Mon Sep 17 00:00:00 2001 From: Ramiro Saenz Date: Tue, 12 Jul 2016 21:50:00 -0300 Subject: [PATCH] Fixed audio and notifications edition for services Fixed #56 --- app/ux/WebView.js | 24 +++++++++++++++++++++++- app/view/main/MainController.js | 14 +++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/app/ux/WebView.js b/app/ux/WebView.js index fb561eed..cc3ef79d 100644 --- a/app/ux/WebView.js +++ b/app/ux/WebView.js @@ -122,7 +122,11 @@ Ext.define('Rambox.ux.WebView',{ webview.addEventListener("dom-ready", function(e) { // 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 if ( me.record && me.record.get('js_unread') !== '' ) { @@ -184,4 +188,22 @@ Ext.define('Rambox.ux.WebView',{ 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 })();'); + } + } }); diff --git a/app/view/main/MainController.js b/app/view/main/MainController.js index 14a53393..440953fb 100644 --- a/app/view/main/MainController.js +++ b/app/view/main/MainController.js @@ -135,6 +135,10 @@ Ext.define('Rambox.view.main.MainController', { }); // Change the title of the Tab 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 if ( oldData.align !== formValues.align ) { if ( formValues.align === 'left' ) { @@ -316,6 +320,10 @@ Ext.define('Rambox.view.main.MainController', { }); // Change the title of the Tab 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 if ( oldData.align !== formValues.align ) { if ( formValues.align === 'left' ) { @@ -590,6 +598,10 @@ Ext.define('Rambox.view.main.MainController', { // Change the title of the Tab 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 Ext.getCmp('tab_'+record.get('id')).setIcon(record.get('logo') === '' ? 'resources/icons/custom.png' : record.get('logo')); // Change the align of the Tab @@ -717,7 +729,7 @@ Ext.define('Rambox.view.main.MainController', { var tab = Ext.getCmp('tab_'+serviceId); // Mute sounds - tab.down('component').el.dom.getWebContents().setAudioMuted(btn.pressed); + tab.setAudioMuted(btn.pressed); // Prevent Notifications if ( btn.pressed ) {