From aabf18c6a0804068da8e30d27859c695e42eafd0 Mon Sep 17 00:00:00 2001 From: Yuya Ochiai Date: Fri, 24 Nov 2017 00:41:38 +0900 Subject: [PATCH 1/2] Support React 16 of webapp for loading icon data-reactroot is no longer used in React 16 https://stackoverflow.com/questions/47203183/missing-data-reactroot-attirbute-in-react-16 --- src/browser/webview/mattermost.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/browser/webview/mattermost.js b/src/browser/webview/mattermost.js index f229411a..284f2b5c 100644 --- a/src/browser/webview/mattermost.js +++ b/src/browser/webview/mattermost.js @@ -12,11 +12,11 @@ Notification = EnhancedNotification; // eslint-disable-line no-global-assign, no Reflect.deleteProperty(global.Buffer); // http://electron.atom.io/docs/tutorial/security/#buffer-global function isReactAppInitialized() { - const reactRoot = document.querySelector('div[data-reactroot]'); - if (reactRoot === null) { + const initializedRoot = document.querySelector('div[data-reactroot]') || document.querySelector('#root.channel-view'); + if (initializedRoot === null) { return false; } - return reactRoot.children.length !== 0; + return initializedRoot.children.length !== 0; } function watchReactAppUntilInitialized(callback) { From a28176a6d79c063c061f778000d0b8eb21706f1d Mon Sep 17 00:00:00 2001 From: Yuya Ochiai Date: Mon, 27 Nov 2017 23:46:42 +0900 Subject: [PATCH 2/2] Add the case where the user is not logged in webapp --- src/browser/webview/mattermost.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/browser/webview/mattermost.js b/src/browser/webview/mattermost.js index 284f2b5c..c6b5052c 100644 --- a/src/browser/webview/mattermost.js +++ b/src/browser/webview/mattermost.js @@ -12,7 +12,10 @@ Notification = EnhancedNotification; // eslint-disable-line no-global-assign, no Reflect.deleteProperty(global.Buffer); // http://electron.atom.io/docs/tutorial/security/#buffer-global function isReactAppInitialized() { - const initializedRoot = document.querySelector('div[data-reactroot]') || document.querySelector('#root.channel-view'); + const initializedRoot = + document.querySelector('#root.channel-view') || // React 16 webapp + document.querySelector('#root .signup-team__container') || // React 16 login + document.querySelector('div[data-reactroot]'); // Older React apps if (initializedRoot === null) { return false; }