1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-11-08 21:42:24 +03:00

Display new rooms as they arrive

This commit is contained in:
David Baker
2015-06-19 16:12:22 +01:00
parent 1270bc3c62
commit 41014af471
2 changed files with 12 additions and 0 deletions

View File

@@ -8,6 +8,7 @@ var RoomTile = ComponentBroker.get("molecules/RoomTile");
module.exports = {
componentWillMount: function() {
var cli = MatrixClientPeg.get();
cli.on("Room", this.onRoom);
cli.on("Room.timeline", this.onRoomTimeline);
this.setState({
@@ -18,6 +19,7 @@ module.exports = {
componentWillUnmount: function() {
if (MatrixClientPeg.get()) {
MatrixClientPeg.get().removeListener("Room", this.onRoom);
MatrixClientPeg.get().removeListener("Room.timeline", this.onRoomTimeline);
}
},
@@ -29,6 +31,13 @@ module.exports = {
});
},
onRoom: function(room) {
var cli = MatrixClientPeg.get();
this.setState({
roomList: cli.getRooms(),
});
},
onRoomTimeline: function(ev, room, toStartOfTimeline) {
if (room.roomId == this.props.selectedRoom) return;
if (ev.getSender() == MatrixClientPeg.get().credentials.userId) return;
@@ -51,6 +60,7 @@ module.exports = {
key={room.roomId}
selected={selected}
unread={that.state.activityMap[room.roomId] === 1}
highlight={that.state.activityMap[room.roomId] === 2}
/>
);
});