Fix cold open of the RightPanel directly to MemberInfo
This requires us to track some of the phase's state in the RightPanelStore, which is not great - trying to get it through the app is a bit difficult.pull/21833/head
parent
78ce801c25
commit
94ae06db4d
|
@ -36,7 +36,7 @@ export default class RightPanel extends React.Component {
|
||||||
return {
|
return {
|
||||||
roomId: PropTypes.string, // if showing panels for a given room, this is set
|
roomId: PropTypes.string, // if showing panels for a given room, this is set
|
||||||
groupId: PropTypes.string, // if showing panels for a given group, this is set
|
groupId: PropTypes.string, // if showing panels for a given group, this is set
|
||||||
user: PropTypes.object,
|
user: PropTypes.object, // used if we know the user ahead of opening the panel
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,6 +51,7 @@ export default class RightPanel extends React.Component {
|
||||||
this.state = {
|
this.state = {
|
||||||
phase: this._getPhaseFromProps(),
|
phase: this._getPhaseFromProps(),
|
||||||
isUserPrivilegedInGroup: null,
|
isUserPrivilegedInGroup: null,
|
||||||
|
member: this._getUserForPanel(),
|
||||||
};
|
};
|
||||||
this.onAction = this.onAction.bind(this);
|
this.onAction = this.onAction.bind(this);
|
||||||
this.onRoomStateMember = this.onRoomStateMember.bind(this);
|
this.onRoomStateMember = this.onRoomStateMember.bind(this);
|
||||||
|
@ -63,6 +64,14 @@ export default class RightPanel extends React.Component {
|
||||||
}, 500);
|
}, 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Helper function to split out the logic for _getPhaseFromProps() and the constructor
|
||||||
|
// as both are called at the same time in the constructor.
|
||||||
|
_getUserForPanel() {
|
||||||
|
if (this.state && this.state.member) return this.state.member;
|
||||||
|
const lastParams = RightPanelStore.getSharedInstance().roomPanelPhaseParams;
|
||||||
|
return this.props.user || lastParams['member'];
|
||||||
|
}
|
||||||
|
|
||||||
_getPhaseFromProps() {
|
_getPhaseFromProps() {
|
||||||
const rps = RightPanelStore.getSharedInstance();
|
const rps = RightPanelStore.getSharedInstance();
|
||||||
if (this.props.groupId) {
|
if (this.props.groupId) {
|
||||||
|
@ -71,7 +80,7 @@ export default class RightPanel extends React.Component {
|
||||||
return RIGHT_PANEL_PHASES.GroupMemberList;
|
return RIGHT_PANEL_PHASES.GroupMemberList;
|
||||||
}
|
}
|
||||||
return rps.groupPanelPhase;
|
return rps.groupPanelPhase;
|
||||||
} else if (this.props.user) {
|
} else if (this._getUserForPanel()) {
|
||||||
return RIGHT_PANEL_PHASES.RoomMemberInfo;
|
return RIGHT_PANEL_PHASES.RoomMemberInfo;
|
||||||
} else {
|
} else {
|
||||||
if (!RIGHT_PANEL_PHASES_NO_ARGS.includes(rps.roomPanelPhase)) {
|
if (!RIGHT_PANEL_PHASES_NO_ARGS.includes(rps.roomPanelPhase)) {
|
||||||
|
@ -87,9 +96,6 @@ export default class RightPanel extends React.Component {
|
||||||
const cli = this.context.matrixClient;
|
const cli = this.context.matrixClient;
|
||||||
cli.on("RoomState.members", this.onRoomStateMember);
|
cli.on("RoomState.members", this.onRoomStateMember);
|
||||||
this._initGroupStore(this.props.groupId);
|
this._initGroupStore(this.props.groupId);
|
||||||
if (this.props.user) {
|
|
||||||
this.setState({member: this.props.user});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
|
|
|
@ -28,6 +28,9 @@ const INITIAL_STATE = {
|
||||||
// The last phase (screen) the right panel was showing
|
// The last phase (screen) the right panel was showing
|
||||||
lastRoomPhase: SettingsStore.getValue("lastRightPanelPhaseForRoom"),
|
lastRoomPhase: SettingsStore.getValue("lastRightPanelPhaseForRoom"),
|
||||||
lastGroupPhase: SettingsStore.getValue("lastRightPanelPhaseForGroup"),
|
lastGroupPhase: SettingsStore.getValue("lastRightPanelPhaseForGroup"),
|
||||||
|
|
||||||
|
// Extra information about the last phase
|
||||||
|
lastRoomPhaseParams: {},
|
||||||
};
|
};
|
||||||
|
|
||||||
const GROUP_PHASES = Object.keys(RIGHT_PANEL_PHASES).filter(k => k.startsWith("Group"));
|
const GROUP_PHASES = Object.keys(RIGHT_PANEL_PHASES).filter(k => k.startsWith("Group"));
|
||||||
|
@ -72,6 +75,10 @@ export default class RightPanelStore extends Store {
|
||||||
return this.isOpenForGroup ? this.groupPanelPhase : null;
|
return this.isOpenForGroup ? this.groupPanelPhase : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get roomPanelPhaseParams(): any {
|
||||||
|
return this._state.lastRoomPhaseParams || {};
|
||||||
|
}
|
||||||
|
|
||||||
_setState(newState) {
|
_setState(newState) {
|
||||||
this._state = Object.assign(this._state, newState);
|
this._state = Object.assign(this._state, newState);
|
||||||
|
|
||||||
|
@ -142,6 +149,7 @@ export default class RightPanelStore extends Store {
|
||||||
this._setState({
|
this._setState({
|
||||||
lastRoomPhase: targetPhase,
|
lastRoomPhase: targetPhase,
|
||||||
showRoomPanel: true,
|
showRoomPanel: true,
|
||||||
|
lastRoomPhaseParams: payload.refireParams || {},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue