diff --git a/src/browser/js/WebappConnector.js b/src/browser/js/WebappConnector.js deleted file mode 100644 index 33ba4257..00000000 --- a/src/browser/js/WebappConnector.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. -// See LICENSE.txt for license information. - -import EventEmitter from 'events'; - -/** -* Provides the bridging infrastructure to connect the desktop and webapp together -*/ -export default class WebappConnector extends EventEmitter { - constructor() { - super(); - - this.active = true; - - window.webappConnector = this; - } -} diff --git a/src/browser/webview/mattermost.js b/src/browser/webview/mattermost.js index 118c7506..d890d160 100644 --- a/src/browser/webview/mattermost.js +++ b/src/browser/webview/mattermost.js @@ -6,14 +6,11 @@ import {ipcRenderer, webFrame} from 'electron'; import EnhancedNotification from '../js/notification'; -import WebappConnector from '../js/WebappConnector'; const UNREAD_COUNT_INTERVAL = 1000; //eslint-disable-next-line no-magic-numbers const CLEAR_CACHE_INTERVAL = 6 * 60 * 60 * 1000; // 6 hours -const webappConnector = new WebappConnector(); - Notification = EnhancedNotification; // eslint-disable-line no-global-assign, no-native-reassign Reflect.deleteProperty(global.Buffer); // http://electron.atom.io/docs/tutorial/security/#buffer-global @@ -201,9 +198,9 @@ function setSpellChecker() { setSpellChecker(); ipcRenderer.on('set-spellchecker', setSpellChecker); -// push user activity updates to the webapp via the communication bridge +// push user activity updates to the webapp ipcRenderer.on('user-activity-update', (event, {userIsActive, isSystemEvent}) => { - webappConnector.emit('user-activity-update', {userIsActive, manual: isSystemEvent}); + window.postMessage({type: 'user-activity-update', message: {userIsActive, manual: isSystemEvent}}, window.location.origin); }); // mattermost-webapp is SPA. So cache is not cleared due to no navigation.