From 9e9a2eddd11d2ff8481c1e66215d916a50995f0c Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Mon, 20 Nov 2017 14:20:33 +0100 Subject: fix(macOS): Fix touchbar related crash on macOS 10.12.1 and lower Closes #70 --- src/lib/TouchBar.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/lib/TouchBar.js b/src/lib/TouchBar.js index ad7849b8e..6831c7870 100644 --- a/src/lib/TouchBar.js +++ b/src/lib/TouchBar.js @@ -1,3 +1,5 @@ +import os from 'os'; +import semver from 'semver'; import { remote } from 'electron'; import { autorun } from 'mobx'; @@ -8,17 +10,23 @@ export default class FranzTouchBar { this.stores = stores; this.actions = actions; - this._initializeReactions(); - } - - _initializeReactions() { - this.build = autorun(this._build.bind(this)); + // Temporary fix for https://github.com/electron/electron/issues/10442 + // TODO: remove when we upgrade to electron 1.8.2 or later + try { + if (isMac && semver.gt(os.release(), '16.6.0')) { + this.build = autorun(this._build.bind(this)); + } + } catch (err) { + console.error(err); + } } _build() { const currentWindow = remote.getCurrentWindow(); - if (isMac && this.stores.user.isLoggedIn) { + currentWindow._setEscapeTouchBarItem = () => {}; + + if (this.stores.user.isLoggedIn) { const { TouchBar } = remote; const { TouchBarButton, TouchBarSpacer } = TouchBar; -- cgit v1.2.3-54-g00ecf