Skip to content
This repository has been archived by the owner on Apr 22, 2022. It is now read-only.

Commit

Permalink
Fix: Skype not loading and issues with badges and notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
fvulich committed Nov 21, 2019
1 parent 48e4e9f commit 30d9383
Showing 1 changed file with 32 additions and 29 deletions.
61 changes: 32 additions & 29 deletions app/ux/WebView.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 30d9383

Please sign in to comment.