Merge pull request #1315 from matrix-org/luke/fix-apps-auto-integs
Stop integ manager opening on every room switch
This commit is contained in:
commit
3c7eec711b
1 changed files with 29 additions and 15 deletions
|
@ -53,10 +53,6 @@ module.exports = React.createClass({
|
||||||
this.scalarClient = new ScalarAuthClient();
|
this.scalarClient = new ScalarAuthClient();
|
||||||
this.scalarClient.connect().done(() => {
|
this.scalarClient.connect().done(() => {
|
||||||
this.forceUpdate();
|
this.forceUpdate();
|
||||||
if (this.state.apps && this.state.apps.length < 1) {
|
|
||||||
// XXX: This should not be called here, we should do something much nicer
|
|
||||||
this.onClickAddWidget();
|
|
||||||
}
|
|
||||||
// TODO -- Handle Scalar errors
|
// TODO -- Handle Scalar errors
|
||||||
// },
|
// },
|
||||||
// (err) => {
|
// (err) => {
|
||||||
|
@ -65,6 +61,8 @@ module.exports = React.createClass({
|
||||||
// });
|
// });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.dispatcherRef = dis.register(this.onAction.bind(this));
|
||||||
},
|
},
|
||||||
|
|
||||||
componentWillUnmount: function() {
|
componentWillUnmount: function() {
|
||||||
|
@ -72,6 +70,27 @@ module.exports = React.createClass({
|
||||||
if (MatrixClientPeg.get()) {
|
if (MatrixClientPeg.get()) {
|
||||||
MatrixClientPeg.get().removeListener("RoomState.events", this.onRoomStateEvents);
|
MatrixClientPeg.get().removeListener("RoomState.events", this.onRoomStateEvents);
|
||||||
}
|
}
|
||||||
|
dis.unregister(this.dispatcherRef);
|
||||||
|
},
|
||||||
|
|
||||||
|
componentWillReceiveProps(newProps) {
|
||||||
|
// Room has changed probably, update apps
|
||||||
|
this._updateApps();
|
||||||
|
},
|
||||||
|
|
||||||
|
onAction: function(action) {
|
||||||
|
switch (action.action) {
|
||||||
|
case 'appsDrawer':
|
||||||
|
// When opening the app draw when there aren't any apps, auto-launch the
|
||||||
|
// integrations manager to skip the awkward click on "Add widget"
|
||||||
|
if (action.show) {
|
||||||
|
const apps = this._getApps();
|
||||||
|
if (apps.length === 0) {
|
||||||
|
this._launchManageIntegrations();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -139,12 +158,6 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
_updateApps: function() {
|
_updateApps: function() {
|
||||||
const apps = this._getApps();
|
const apps = this._getApps();
|
||||||
if (apps.length < 1) {
|
|
||||||
dis.dispatch({
|
|
||||||
action: 'appsDrawer',
|
|
||||||
show: false,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
this.setState({
|
this.setState({
|
||||||
apps: apps,
|
apps: apps,
|
||||||
});
|
});
|
||||||
|
@ -159,11 +172,7 @@ module.exports = React.createClass({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onClickAddWidget: function(e) {
|
_launchManageIntegrations: function() {
|
||||||
if (e) {
|
|
||||||
e.preventDefault();
|
|
||||||
}
|
|
||||||
|
|
||||||
const IntegrationsManager = sdk.getComponent("views.settings.IntegrationsManager");
|
const IntegrationsManager = sdk.getComponent("views.settings.IntegrationsManager");
|
||||||
const src = (this.scalarClient !== null && this.scalarClient.hasCredentials()) ?
|
const src = (this.scalarClient !== null && this.scalarClient.hasCredentials()) ?
|
||||||
this.scalarClient.getScalarInterfaceUrlForRoom(this.props.room.roomId, 'add_integ') :
|
this.scalarClient.getScalarInterfaceUrlForRoom(this.props.room.roomId, 'add_integ') :
|
||||||
|
@ -173,6 +182,11 @@ module.exports = React.createClass({
|
||||||
}, "mx_IntegrationsManager");
|
}, "mx_IntegrationsManager");
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onClickAddWidget: function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
this._launchManageIntegrations();
|
||||||
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
const apps = this.state.apps.map(
|
const apps = this.state.apps.map(
|
||||||
(app, index, arr) => {
|
(app, index, arr) => {
|
||||||
|
|
Loading…
Reference in a new issue