From e22d0a53b6924c24dc6d5fab61a6e138a57a16c5 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Tue, 6 Sep 2016 00:59:17 +0100 Subject: [PATCH] WIP switch-over of TimePanel from taking Rooms to taking EventTimelineSets --- src/components/structures/FilePanel.js | 46 +++++- src/components/structures/RoomView.js | 4 +- src/components/structures/TimelinePanel.js | 140 ++++++++++-------- .../structures/TimelinePanel-test.js | 17 ++- 4 files changed, 139 insertions(+), 68 deletions(-) diff --git a/src/components/structures/FilePanel.js b/src/components/structures/FilePanel.js index 6e1f5e4633..f43a848568 100644 --- a/src/components/structures/FilePanel.js +++ b/src/components/structures/FilePanel.js @@ -27,6 +27,46 @@ var dis = require("../../dispatcher"); var FilePanel = React.createClass({ displayName: 'FilePanel', + propTypes: { + roomId: React.PropTypes.string.isRequired, + }, + + getInitialState: function() { + return { + room: MatrixClientPeg.get().getRoom(this.props.roomId), + timelineSet: null, + } + }, + + componentWillMount: function() { + if (this.state.room) { + var client = MatrixClientPeg.get(); + var filter = new Matrix.Filter(client.credentials.userId); + filter.setDefinition( + { + "room": { + "timeline": { + "contains_url": true + }, + } + } + ); + + client.getOrCreateFilter("FILTER_FILES_" + client.credentials.userId, filter).then( + (filterId)=>{ + var timelineSet = this.state.room.getOrCreateFilteredTimelineSet(filter); + this.setState({ timelineSet: timelineSet }); + }, + (error)=>{ + console.error("Failed to get or create file panel filter", error); + } + ); + } + else { + console.error("Failed to add filtered timelineSet for FilePanel as no room!"); + } + }, + // this has to be a proper method rather than an unnamed function, // otherwise react calls it with null on each update. _gatherTimelinePanelRef: function(r) { @@ -36,8 +76,6 @@ var FilePanel = React.createClass({ render: function() { // wrap a TimelinePanel with the jump-to-event bits turned off. - var room = MatrixClientPeg.get().getRoom(this.props.roomId); - //