Display new rooms as they arrive

pull/1/head
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}
/>
);
});

View File

@ -1,3 +1,5 @@
var React = require('react');
var MatrixClientPeg = require("../../MatrixClientPeg");
var Matrix = require("matrix-js-sdk");