From 30d93831df940e1ccd7a0634dd678d80389eb9a2 Mon Sep 17 00:00:00 2001 From: Vulich Fernando <46904390+fvulich@users.noreply.github.com> Date: Thu, 21 Nov 2019 12:58:22 -0300 Subject: [PATCH] Fix: Skype not loading and issues with badges and notifications --- app/ux/WebView.js | 61 +++++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/app/ux/WebView.js b/app/ux/WebView.js index c90d2b453..8099d09c8 100644 --- a/app/ux/WebView.js +++ b/app/ux/WebView.js @@ -456,6 +456,7 @@ Ext.define('Rambox.ux.WebView',{ e.preventDefault(); }); + let eventsOnDom = false; webview.addEventListener("dom-ready", function(e) { // Mute Webview if ( me.record.get('muted') || localStorage.getItem('locked') || JSON.parse(localStorage.getItem('dontDisturb')) ) me.setAudioMuted(true, true); @@ -501,38 +502,40 @@ Ext.define('Rambox.ux.WebView',{ }); me.down('statusbar').down('button').show(); }); + if (!eventsOnDom) { + webview.getWebContents().on('before-input-event', (event, input) => { + if (input.type !== 'keyDown') return; + + var modifiers = []; + if ( input.shift ) modifiers.push('shift'); + if ( input.control ) modifiers.push('control'); + if ( input.alt ) modifiers.push('alt'); + if ( input.meta ) modifiers.push('meta'); + if ( input.isAutoRepeat ) modifiers.push('isAutoRepeat'); + + if ( input.key === 'Tab' && !(modifiers && modifiers.length) ) return; + + // Maps special keys to fire the correct event in Mac OS + if ( require('electron').remote.process.platform === 'darwin' ) { + var keys = []; + keys['ƒ'] = 'f'; // Search + keys[' '] = 'l'; // Lock + + input.key = keys[input.key] ? keys[input.key] : input.key; + } - webview.executeJavaScript(js_inject).then(result => {} ).catch(err => { console.log(err) }) - }); - webview.getWebContents().on('before-input-event', (event, input) => { - if (input.type !== 'keyDown') return; - - var modifiers = []; - if ( input.shift ) modifiers.push('shift'); - if ( input.control ) modifiers.push('control'); - if ( input.alt ) modifiers.push('alt'); - if ( input.meta ) modifiers.push('meta'); - if ( input.isAutoRepeat ) modifiers.push('isAutoRepeat'); - - if ( input.key === 'Tab' && !(modifiers && modifiers.length) ) return; - - // Maps special keys to fire the correct event in Mac OS - if ( require('electron').remote.process.platform === 'darwin' ) { - var keys = []; - keys['ƒ'] = 'f'; // Search - keys[' '] = 'l'; // Lock + if ( input.key === 'F11' || input.key === 'F12' || input.key === 'q' || (input.key === 'F1' && modifiers.includes('control'))) return; - input.key = keys[input.key] ? keys[input.key] : input.key; + require('electron').remote.getCurrentWebContents().sendInputEvent({ + type: input.type, + keyCode: input.key, + modifiers: modifiers + }); + }) + eventsOnDom = true; } - - if ( input.key === 'F11' || input.key === 'F12' || input.key === 'q' || (input.key === 'F1' && modifiers.includes('control'))) return; - - require('electron').remote.getCurrentWebContents().sendInputEvent({ - type: input.type, - keyCode: input.key, - modifiers: modifiers - }); - }) + webview.executeJavaScript(js_inject).then(result => {} ).catch(err => { console.log(err) }) + }); webview.addEventListener('ipc-message', function(event) { var channel = event.channel;