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);
-
//
diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js
index 041493d420..73d1b8582b 100644
--- a/src/components/structures/RoomView.js
+++ b/src/components/structures/RoomView.js
@@ -1570,7 +1570,9 @@ module.exports = React.createClass({
var messagePanel = (
{ return e.getId() == rmId });
@@ -622,7 +640,9 @@ var TimelinePanel = React.createClass({
// 0: read marker is visible
// +1: read marker is below the window
getReadMarkerPosition: function() {
- if (!this.refs.messagePanel) { return null; }
+ if (!this.props.manageReadMarkers) return null;
+ if (!this.refs.messagePanel) return null;
+
var ret = this.refs.messagePanel.getReadMarkerPosition();
if (ret !== null) {
return ret;
@@ -630,7 +650,7 @@ var TimelinePanel = React.createClass({
// the messagePanel doesn't know where the read marker is.
// if we know the timestamp of the read marker, make a guess based on that.
- var rmTs = TimelinePanel.roomReadMarkerTsMap[this.props.room.roomId];
+ var rmTs = TimelinePanel.roomReadMarkerTsMap[this.props.timelineSet.roomId];
if (rmTs && this.state.events.length > 0) {
if (rmTs < this.state.events[0].getTs()) {
return -1;
@@ -691,7 +711,7 @@ var TimelinePanel = React.createClass({
*/
_loadTimeline: function(eventId, pixelOffset, offsetBase) {
this._timelineWindow = new Matrix.TimelineWindow(
- MatrixClientPeg.get(), this.props.room,
+ MatrixClientPeg.get(), this.props.timelineSet,
{windowLimit: this.props.timelineCap});
var onLoaded = () => {
@@ -745,7 +765,7 @@ var TimelinePanel = React.createClass({
// go via the dispatcher so that the URL is updated
dis.dispatch({
action: 'view_room',
- room_id: this.props.room.roomId,
+ room_id: this.props.timelineSet.roomId,
});
};
}
@@ -807,7 +827,7 @@ var TimelinePanel = React.createClass({
// if we're at the end of the live timeline, append the pending events
if (!this._timelineWindow.canPaginate(EventTimeline.FORWARDS)) {
- events.push(... this.props.room.getPendingEvents());
+ events.push(... this.props.timelineSet.room.getPendingEvents());
}
return events;
@@ -873,11 +893,13 @@ var TimelinePanel = React.createClass({
return null;
var myUserId = client.credentials.userId;
- return this.props.room.getEventReadUpTo(myUserId, ignoreSynthesized);
+ return this.props.timelineSet.room.getEventReadUpTo(myUserId, ignoreSynthesized);
},
_setReadMarker: function(eventId, eventTs, inhibitSetState) {
- if (TimelinePanel.roomReadMarkerMap[this.props.room.roomId] == eventId) {
+ var roomId = this.props.timelineSet.room.roomId;
+
+ if (TimelinePanel.roomReadMarkerMap[roomId] == eventId) {
// don't update the state (and cause a re-render) if there is
// no change to the RM.
return;
@@ -885,11 +907,11 @@ var TimelinePanel = React.createClass({
// ideally we'd sync these via the server, but for now just stash them
// in a map.
- TimelinePanel.roomReadMarkerMap[this.props.room.roomId] = eventId;
+ TimelinePanel.roomReadMarkerMap[roomId] = eventId;
// in order to later figure out if the read marker is
// above or below the visible timeline, we stash the timestamp.
- TimelinePanel.roomReadMarkerTsMap[this.props.room.roomId] = eventTs;
+ TimelinePanel.roomReadMarkerTsMap[roomId] = eventTs;
if (inhibitSetState) {
return;
diff --git a/test/components/structures/TimelinePanel-test.js b/test/components/structures/TimelinePanel-test.js
index 027d888d2d..4683637a1b 100644
--- a/test/components/structures/TimelinePanel-test.js
+++ b/test/components/structures/TimelinePanel-test.js
@@ -35,6 +35,7 @@ var USER_ID = '@me:localhost';
describe('TimelinePanel', function() {
var sandbox;
+ var timelineSet;
var room;
var client;
var timeline;
@@ -60,9 +61,12 @@ describe('TimelinePanel', function() {
timeline = new jssdk.EventTimeline(ROOM_ID);
room = sinon.createStubInstance(jssdk.Room);
- room.getLiveTimeline.returns(timeline);
room.getPendingEvents.returns([]);
+ timelineSet = sinon.createStubInstance(jssdk.EventTimelineSet);
+ timelineSet.getLiveTimeline.returns(timeline);
+ timelineSet.room = room;
+
client = peg.get();
client.credentials = {userId: USER_ID};
@@ -95,7 +99,7 @@ describe('TimelinePanel', function() {
var scrollDefer;
var panel = ReactDOM.render(
- {scrollDefer.resolve()}}
+ {scrollDefer.resolve()}}
/>,
parentDiv,
);
@@ -143,7 +147,10 @@ describe('TimelinePanel', function() {
// a new event!
var ev = mkMessage();
timeline.addEvent(ev);
- panel.onRoomTimeline(ev, room, false, false, {liveEvent: true});
+ panel.onRoomTimeline(ev, room, false, false, {
+ liveEvent: true,
+ timelineSet: timelineSet,
+ });
// that won't make much difference, because we don't paginate
// unless we're at the bottom of the timeline, but a scroll event
@@ -178,7 +185,7 @@ describe('TimelinePanel', function() {
});
var panel = ReactDOM.render(
- ,
+ ,
parentDiv
);
@@ -226,7 +233,7 @@ describe('TimelinePanel', function() {
var scrollDefer;
var panel = ReactDOM.render(
- {scrollDefer.resolve()}}
+ {scrollDefer.resolve()}}
timelineCap={TIMELINE_CAP}
/>,
parentDiv