Display new rooms as they arrive
							parent
							
								
									1270bc3c62
								
							
						
					
					
						commit
						41014af471
					
				|  | @ -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} | ||||
|                 /> | ||||
|             ); | ||||
|         }); | ||||
|  |  | |||
|  | @ -1,3 +1,5 @@ | |||
| var React = require('react'); | ||||
| 
 | ||||
| var MatrixClientPeg = require("../../MatrixClientPeg"); | ||||
| var Matrix = require("matrix-js-sdk"); | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 David Baker
						David Baker