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); - //