Add group member right panel

This commit is contained in:
David Baker 2017-08-09 15:36:51 +01:00
parent 12628b67ea
commit 7c4b6739fc

View File

@ -42,6 +42,7 @@ module.exports = React.createClass({
FilePanel: 'FilePanel', FilePanel: 'FilePanel',
NotificationPanel: 'NotificationPanel', NotificationPanel: 'NotificationPanel',
RoomMemberInfo: 'RoomMemberInfo', RoomMemberInfo: 'RoomMemberInfo',
GroupMemberInfo: 'GroupMemberInfo',
}, },
componentWillMount: function() { componentWillMount: function() {
@ -57,6 +58,10 @@ module.exports = React.createClass({
} }
}, },
componentWillReceiveProps: function(newprops) {
this.setState(this.getInitialState());
},
getInitialState: function() { getInitialState: function() {
if (this.props.userId) { if (this.props.userId) {
const member = new Matrix.RoomMember(null, this.props.userId); const member = new Matrix.RoomMember(null, this.props.userId);
@ -142,12 +147,19 @@ module.exports = React.createClass({
}); });
} else if (this.props.groupId) { } else if (this.props.groupId) {
this.setState({ this.setState({
phase: this.Phase.GroupMemberList phase: this.Phase.GroupMemberList,
groupId: payload.groupId,
member: payload.member,
}); });
} }
} }
} } else if (payload.action === "view_group_user") {
else if (payload.action === "view_room") { this.setState({
phase: this.Phase.GroupMemberInfo,
groupId: payload.groupId,
member: payload.member,
});
} else if (payload.action === "view_room") {
if (this.state.phase === this.Phase.RoomMemberInfo) { if (this.state.phase === this.Phase.RoomMemberInfo) {
this.setState({ this.setState({
phase: this.Phase.RoomMemberList phase: this.Phase.RoomMemberList
@ -239,9 +251,12 @@ module.exports = React.createClass({
panel = <MemberList roomId={this.props.roomId} key={this.props.roomId} /> panel = <MemberList roomId={this.props.roomId} key={this.props.roomId} />
} else if (this.props.groupId && this.state.phase == this.Phase.GroupMemberList) { } else if (this.props.groupId && this.state.phase == this.Phase.GroupMemberList) {
panel = <GroupMemberList groupId={this.props.groupId} key={this.props.groupId} /> panel = <GroupMemberList groupId={this.props.groupId} key={this.props.groupId} />
} else if(this.state.phase == this.Phase.RoomMemberInfo) { } else if (this.state.phase == this.Phase.RoomMemberInfo) {
const MemberInfo = sdk.getComponent('rooms.MemberInfo'); const MemberInfo = sdk.getComponent('rooms.MemberInfo');
panel = <MemberInfo member={this.state.member} key={this.props.roomId || this.props.userId} /> panel = <MemberInfo member={this.state.member} key={this.props.roomId || this.props.userId} />
} else if (this.state.phase == this.Phase.GroupMemberInfo) {
const GroupMemberInfo = sdk.getComponent('groups.GroupMemberInfo');
panel = <GroupMemberInfo member={this.state.member} groupId={this.props.groupId} key={this.state.member.user_id} />
} else if (this.state.phase == this.Phase.NotificationPanel) { } else if (this.state.phase == this.Phase.NotificationPanel) {
panel = <NotificationPanel /> panel = <NotificationPanel />
} else if (this.state.phase == this.Phase.FilePanel) { } else if (this.state.phase == this.Phase.FilePanel) {