Skip to content

Commit 9e9a2ed

Browse files
committed
fix(macOS): Fix touchbar related crash on macOS 10.12.1 and lower
Closes #70
1 parent d8fe163 commit 9e9a2ed

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
"react-sortable-hoc": "^0.6.7",
6666
"react-tooltip": "^3.2.7",
6767
"route-parser": "^0.0.5",
68+
"semver": "^5.4.1",
6869
"smoothscroll-polyfill": "^0.3.4",
6970
"tar": "^4.0.2",
7071
"uuid": "^3.0.1"

src/lib/TouchBar.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import os from 'os';
2+
import semver from 'semver';
13
import { remote } from 'electron';
24
import { autorun } from 'mobx';
35

@@ -8,17 +10,23 @@ export default class FranzTouchBar {
810
this.stores = stores;
911
this.actions = actions;
1012

11-
this._initializeReactions();
12-
}
13-
14-
_initializeReactions() {
15-
this.build = autorun(this._build.bind(this));
13+
// Temporary fix for https://github.com/electron/electron/issues/10442
14+
// TODO: remove when we upgrade to electron 1.8.2 or later
15+
try {
16+
if (isMac && semver.gt(os.release(), '16.6.0')) {
17+
this.build = autorun(this._build.bind(this));
18+
}
19+
} catch (err) {
20+
console.error(err);
21+
}
1622
}
1723

1824
_build() {
1925
const currentWindow = remote.getCurrentWindow();
2026

21-
if (isMac && this.stores.user.isLoggedIn) {
27+
currentWindow._setEscapeTouchBarItem = () => {};
28+
29+
if (this.stores.user.isLoggedIn) {
2230
const { TouchBar } = remote;
2331
const { TouchBarButton, TouchBarSpacer } = TouchBar;
2432

0 commit comments

Comments
 (0)