Keymaps are now updated without restarting (#2455)

* Reload keymaps without restarting

* Reattach key listeners when config have changed
This commit is contained in:
CHaBou 2017-11-15 00:55:21 +01:00 committed by GitHub
parent 319ff3bcd7
commit 81709073cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 37 additions and 25 deletions

View file

@ -20,6 +20,9 @@ class Hyper extends PureComponent {
this.handleFocusActive = this.handleFocusActive.bind(this);
this.onTermsRef = this.onTermsRef.bind(this);
this.mousetrap = null;
this.state = {
lastConfigUpdate: 0
};
}
componentWillReceiveProps(next) {
@ -28,6 +31,11 @@ class Hyper extends PureComponent {
// starts working again
document.body.style.backgroundColor = next.backgroundColor;
}
const {lastConfigUpdate} = next;
if (lastConfigUpdate && lastConfigUpdate !== this.state.lastConfigUpdate) {
this.setState({lastConfigUpdate});
this.attachKeyListeners();
}
}
handleFocusActive() {
@ -132,7 +140,8 @@ const HyperContainer = connect(
borderColor: state.ui.borderColor,
activeSession: state.sessions.activeUid,
backgroundColor: state.ui.backgroundColor,
maximized: state.ui.maximized
maximized: state.ui.maximized,
lastConfigUpdate: state.ui._lastUpdate
};
},
dispatch => {