Merge pull request #269 from matrix-org/rav/stop_client_on_unmount
Stop the MatrixClient when the MatrixChat is unmounted
This commit is contained in:
commit
047524d093
1 changed files with 12 additions and 6 deletions
|
@ -185,6 +185,7 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
componentWillUnmount: function() {
|
componentWillUnmount: function() {
|
||||||
|
this._stopMatrixClient();
|
||||||
dis.unregister(this.dispatcherRef);
|
dis.unregister(this.dispatcherRef);
|
||||||
document.removeEventListener("keydown", this.onKeyDown);
|
document.removeEventListener("keydown", this.onKeyDown);
|
||||||
window.removeEventListener("focus", this.onFocus);
|
window.removeEventListener("focus", this.onFocus);
|
||||||
|
@ -260,12 +261,7 @@ module.exports = React.createClass({
|
||||||
window.localStorage.setItem("mx_hs_url", hsUrl);
|
window.localStorage.setItem("mx_hs_url", hsUrl);
|
||||||
window.localStorage.setItem("mx_is_url", isUrl);
|
window.localStorage.setItem("mx_is_url", isUrl);
|
||||||
}
|
}
|
||||||
Notifier.stop();
|
this._stopMatrixClient();
|
||||||
UserActivity.stop();
|
|
||||||
Presence.stop();
|
|
||||||
MatrixClientPeg.get().stopClient();
|
|
||||||
MatrixClientPeg.get().removeAllListeners();
|
|
||||||
MatrixClientPeg.unset();
|
|
||||||
this.notifyNewScreen('login');
|
this.notifyNewScreen('login');
|
||||||
this.replaceState({
|
this.replaceState({
|
||||||
logged_in: false,
|
logged_in: false,
|
||||||
|
@ -730,6 +726,16 @@ module.exports = React.createClass({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// stop all the background processes related to the current client
|
||||||
|
_stopMatrixClient: function() {
|
||||||
|
Notifier.stop();
|
||||||
|
UserActivity.stop();
|
||||||
|
Presence.stop();
|
||||||
|
MatrixClientPeg.get().stopClient();
|
||||||
|
MatrixClientPeg.get().removeAllListeners();
|
||||||
|
MatrixClientPeg.unset();
|
||||||
|
},
|
||||||
|
|
||||||
onKeyDown: function(ev) {
|
onKeyDown: function(ev) {
|
||||||
/*
|
/*
|
||||||
// Remove this for now as ctrl+alt = alt-gr so this breaks keyboards which rely on alt-gr for numbers
|
// Remove this for now as ctrl+alt = alt-gr so this breaks keyboards which rely on alt-gr for numbers
|
||||||
|
|
Loading…
Reference in a new issue