update badge count in realtime
This commit is contained in:
parent
28c3787fb3
commit
d16968d528
|
@ -29,6 +29,17 @@ module.exports = React.createClass({
|
||||||
FileList: 'FileList',
|
FileList: 'FileList',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
componentWillMount: function() {
|
||||||
|
var cli = MatrixClientPeg.get();
|
||||||
|
cli.on("RoomState.members", this.onRoomStateMember);
|
||||||
|
},
|
||||||
|
|
||||||
|
componentWillUnmount: function() {
|
||||||
|
if (MatrixClientPeg.get()) {
|
||||||
|
MatrixClientPeg.get().removeListener("RoomState.members", this.onRoomStateMember);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
getInitialState: function() {
|
getInitialState: function() {
|
||||||
return {
|
return {
|
||||||
phase : this.Phase.MemberList
|
phase : this.Phase.MemberList
|
||||||
|
@ -49,6 +60,13 @@ module.exports = React.createClass({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onRoomStateMember: function(ev, state, member) {
|
||||||
|
// redraw the badge on the membership list
|
||||||
|
if (this.state.phase == this.Phase.MemberList && member.roomId === this.props.roomId) {
|
||||||
|
this.forceUpdate();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
var MemberList = sdk.getComponent('organisms.MemberList');
|
var MemberList = sdk.getComponent('organisms.MemberList');
|
||||||
var buttonGroup;
|
var buttonGroup;
|
||||||
|
@ -69,7 +87,6 @@ module.exports = React.createClass({
|
||||||
if (this.state.phase == this.Phase.MemberList && this.props.roomId) {
|
if (this.state.phase == this.Phase.MemberList && this.props.roomId) {
|
||||||
var cli = MatrixClientPeg.get();
|
var cli = MatrixClientPeg.get();
|
||||||
var room = cli.getRoom(this.props.roomId);
|
var room = cli.getRoom(this.props.roomId);
|
||||||
// FIXME: presumably we need to subscribe to some event to refresh this count when it changes?
|
|
||||||
if (room) {
|
if (room) {
|
||||||
membersBadge = <div className="mx_RightPanel_headerButton_badge">{ room.getJoinedMembers().length }</div>;
|
membersBadge = <div className="mx_RightPanel_headerButton_badge">{ room.getJoinedMembers().length }</div>;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue