From f12f9da798b3dd60109fefce1697e04ea4bc58db Mon Sep 17 00:00:00 2001 From: Dean Whillier Date: Mon, 9 Sep 2019 12:33:14 -0400 Subject: [PATCH] =?UTF-8?q?switch=20to=20=E2=80=98postMessage=E2=80=99=20f?= =?UTF-8?q?or=20webapp=20communication=20(#1026)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/browser/js/WebappConnector.js | 17 ----------------- src/browser/webview/mattermost.js | 7 ++----- 2 files changed, 2 insertions(+), 22 deletions(-) delete mode 100644 src/browser/js/WebappConnector.js 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.