Properly handle closing the panel while verifying

Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
Šimon Brandner 2021-01-30 09:38:10 +01:00
parent 1360f551ce
commit 73ab074219
No known key found for this signature in database
GPG key ID: 9760693FDD98A790

View file

@ -186,7 +186,7 @@ export default class RightPanel extends React.Component {
} }
} }
onCloseUserInfo = () => { onClose = () => {
// XXX: There are three different ways of 'closing' this panel depending on what state // XXX: There are three different ways of 'closing' this panel depending on what state
// things are in... this knows far more than it should do about the state of the rest // things are in... this knows far more than it should do about the state of the rest
// of the app and is generally a bit silly. // of the app and is generally a bit silly.
@ -198,31 +198,21 @@ export default class RightPanel extends React.Component {
dis.dispatch({ dis.dispatch({
action: "view_home_page", action: "view_home_page",
}); });
} else if (this.state.phase === RightPanelPhases.EncryptionPanel && } else if (
this.state.phase === RightPanelPhases.EncryptionPanel &&
this.state.verificationRequest && this.state.verificationRequest.pending this.state.verificationRequest && this.state.verificationRequest.pending
) { ) {
// When the user clicks close on the encryption panel cancel the pending request first if any // When the user clicks close on the encryption panel cancel the pending request first if any
this.state.verificationRequest.cancel(); this.state.verificationRequest.cancel();
} else { } else {
// Otherwise we have got our user from RoomViewStore which means we're being shown // the RightPanelStore has no way of knowing which mode room/group it is in, so we handle closing here
// within a room/group, so go back to the member panel if we were in the encryption panel, defaultDispatcher.dispatch({
// or the member list if we were in the member panel... phew. action: Action.ToggleRightPanel,
const isEncryptionPhase = this.state.phase === RightPanelPhases.EncryptionPanel; type: this.props.groupId ? "group" : "room",
dis.dispatch({
action: Action.ViewUser,
member: isEncryptionPhase ? this.state.member : null,
}); });
} }
}; };
onClose = () => {
// the RightPanelStore has no way of knowing which mode room/group it is in, so we handle closing here
defaultDispatcher.dispatch({
action: Action.ToggleRightPanel,
type: this.props.groupId ? "group" : "room",
});
};
render() { render() {
const MemberList = sdk.getComponent('rooms.MemberList'); const MemberList = sdk.getComponent('rooms.MemberList');
const UserInfo = sdk.getComponent('right_panel.UserInfo'); const UserInfo = sdk.getComponent('right_panel.UserInfo');