Ensure that Scalar Messaging is started and stopped on component mount / unmount

This commit is contained in:
Richard Lewis 2017-06-20 17:56:45 +01:00
parent a449588c1c
commit 68473e118f

View file

@ -24,6 +24,7 @@ import dis from '../../../dispatcher';
import sdk from '../../../index'; import sdk from '../../../index';
import SdkConfig from '../../../SdkConfig'; import SdkConfig from '../../../SdkConfig';
import ScalarAuthClient from '../../../ScalarAuthClient'; import ScalarAuthClient from '../../../ScalarAuthClient';
import ScalarMessaging from '../../../ScalarMessaging';
module.exports = React.createClass({ module.exports = React.createClass({
displayName: 'AppsDrawer', displayName: 'AppsDrawer',
@ -33,6 +34,7 @@ module.exports = React.createClass({
}, },
componentWillMount: function() { componentWillMount: function() {
ScalarMessaging.startListening();
MatrixClientPeg.get().on("RoomState.events", this.onRoomStateEvents); MatrixClientPeg.get().on("RoomState.events", this.onRoomStateEvents);
}, },
@ -55,6 +57,7 @@ module.exports = React.createClass({
}, },
componentWillUnmount: function() { componentWillUnmount: function() {
ScalarMessaging.startListening();
if (MatrixClientPeg.get()) { if (MatrixClientPeg.get()) {
MatrixClientPeg.get().removeListener("RoomState.events", this.onRoomStateEvents); MatrixClientPeg.get().removeListener("RoomState.events", this.onRoomStateEvents);
} }
@ -214,10 +217,8 @@ module.exports = React.createClass({
Modal.createDialog(IntegrationsManager, { Modal.createDialog(IntegrationsManager, {
src: src, src: src,
onFinished: ()=>{ onFinished: ()=>{
if (this._calcSavePromises().length === 0) { if (e) {
if (e) { this.props.onCancelClick(e);
this.props.onCancelClick(e);
}
} }
}, },
}, "mx_IntegrationsManager"); }, "mx_IntegrationsManager");