diff --git a/src/vector/platform/ElectronPlatform.js b/src/vector/platform/ElectronPlatform.js index dd95ce1e..810fa984 100644 --- a/src/vector/platform/ElectronPlatform.js +++ b/src/vector/platform/ElectronPlatform.js @@ -20,6 +20,11 @@ limitations under the License. import VectorBasePlatform from './VectorBasePlatform'; import dis from 'matrix-react-sdk/lib/dispatcher'; +const electron = require('electron'); +const remote = electron.remote; + +electron.remote.autoUpdater.on('update-downloaded', onUpdateDownloaded); + function onUpdateDownloaded(ev, releaseNotes, ver, date, updateURL) { dis.dispatch({ action: 'new_version', @@ -29,14 +34,6 @@ function onUpdateDownloaded(ev, releaseNotes, ver, date, updateURL) { }); } -// index.js imports us unconditionally, so we need this check here as well -let electron = null, remote = null; -if (window && window.process && window.process && window.process.type === 'renderer') { - electron = require('electron'); - electron.remote.autoUpdater.on('update-downloaded', onUpdateDownloaded); - remote = electron.remote; -} - export default class ElectronPlatform extends VectorBasePlatform { setNotificationCount(count: number) { super.setNotificationCount(count); diff --git a/src/vector/platform/index.js b/src/vector/platform/index.js index d2ed1bc9..45b69a72 100644 --- a/src/vector/platform/index.js +++ b/src/vector/platform/index.js @@ -17,16 +17,13 @@ See the License for the specific language governing permissions and limitations under the License. */ -import ElectronPlatform from './ElectronPlatform'; -import WebPlatform from './WebPlatform'; - let Platform = null; if (window && window.process && window.process && window.process.type === 'renderer') { // we're running inside electron - Platform = ElectronPlatform; + Platform = require('./ElectronPlatform');; } else { - Platform = WebPlatform; + Platform = require('./WebPlatform');; } export default Platform;