From 4aef352a5ca606a89b30279859e20283b21e2402 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Thu, 8 Sep 2016 22:48:44 +0100 Subject: [PATCH] update to use new API based on js-sdk PR input --- src/MatrixClientPeg.js | 2 +- src/Notifier.js | 3 ++- src/components/structures/RoomView.js | 3 +++ src/components/structures/TimelinePanel.js | 4 ++-- src/components/views/rooms/RoomList.js | 3 ++- test/components/structures/TimelinePanel-test.js | 9 ++++++--- 6 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/MatrixClientPeg.js b/src/MatrixClientPeg.js index 3ba50769a1..98b698ca3e 100644 --- a/src/MatrixClientPeg.js +++ b/src/MatrixClientPeg.js @@ -107,7 +107,7 @@ class MatrixClientPeg { this.matrixClient.setGuest(Boolean(creds.guest)); - var notifTimelineSet = new EventTimelineSet(null, null, { + var notifTimelineSet = new EventTimelineSet(null, { timelineSupport: true }); // XXX: what is our initial pagination token?! it somehow needs to be synchronised with /sync. diff --git a/src/Notifier.js b/src/Notifier.js index 99fef9d671..c3ece7bbc1 100644 --- a/src/Notifier.js +++ b/src/Notifier.js @@ -224,10 +224,11 @@ var Notifier = { } }, - onRoomTimeline: function(ev, room, toStartOfTimeline) { + onRoomTimeline: function(ev, room, toStartOfTimeline, removed, data) { if (toStartOfTimeline) return; if (!this.isPrepared) return; // don't alert for any messages initially if (ev.sender && ev.sender.userId == MatrixClientPeg.get().credentials.userId) return; + if (data.timeline.getTimelineSet() !== room.getUnfilteredTimelineSet()) return; var actions = MatrixClientPeg.get().getPushActionsForEvent(ev); if (actions && actions.notify) { diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index 37af891db0..9cb113e25c 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -342,6 +342,9 @@ module.exports = React.createClass({ // ignore events for other rooms if (!this.state.room || room.roomId != this.state.room.roomId) return; + // ignore events from filtered timelines + if (data.timeline.getTimelineSet() !== room.getUnfilteredTimelineSet()) return; + if (ev.getType() === "org.matrix.room.preview_urls") { this._updatePreviewUrlVisibility(room); } diff --git a/src/components/structures/TimelinePanel.js b/src/components/structures/TimelinePanel.js index 2a8a684c33..9d559ed4a4 100644 --- a/src/components/structures/TimelinePanel.js +++ b/src/components/structures/TimelinePanel.js @@ -320,8 +320,8 @@ var TimelinePanel = React.createClass({ }, onRoomTimeline: function(ev, room, toStartOfTimeline, removed, data) { - // ignore events for other rooms - if (data.timelineSet !== this.props.timelineSet) return; + // ignore events for other timeline sets + if (data.timeline.getTimelineSet() !== this.props.timelineSet) return; // ignore anything but real-time updates at the end of the room: // updates from pagination will happen when the paginate completes. diff --git a/src/components/views/rooms/RoomList.js b/src/components/views/rooms/RoomList.js index d679a1f4c6..4a4f0dce2f 100644 --- a/src/components/views/rooms/RoomList.js +++ b/src/components/views/rooms/RoomList.js @@ -146,8 +146,9 @@ module.exports = React.createClass({ this._updateStickyHeaders(true, scrollToPosition); }, - onRoomTimeline: function(ev, room, toStartOfTimeline) { + onRoomTimeline: function(ev, room, toStartOfTimeline, removed, data) { if (toStartOfTimeline) return; + if (data.timeline.getTimelineSet() !== room.getUnfilteredTimelineSet()) return; this._delayedRefreshRoomList(); }, diff --git a/test/components/structures/TimelinePanel-test.js b/test/components/structures/TimelinePanel-test.js index c2bb616b0d..993973cb1d 100644 --- a/test/components/structures/TimelinePanel-test.js +++ b/test/components/structures/TimelinePanel-test.js @@ -59,14 +59,17 @@ describe('TimelinePanel', function() { test_utils.beforeEach(this); sandbox = test_utils.stubClient(sandbox); - timeline = new jssdk.EventTimeline(ROOM_ID); room = sinon.createStubInstance(jssdk.Room); + room.roomId = ROOM_ID; timelineSet = sinon.createStubInstance(jssdk.EventTimelineSet); - timelineSet.getLiveTimeline.returns(timeline); timelineSet.getPendingEvents.returns([]); timelineSet.room = room; + timeline = new jssdk.EventTimeline(timelineSet); + + timelineSet.getLiveTimeline.returns(timeline); + client = peg.get(); client.credentials = {userId: USER_ID}; @@ -149,7 +152,7 @@ describe('TimelinePanel', function() { timeline.addEvent(ev); panel.onRoomTimeline(ev, room, false, false, { liveEvent: true, - timelineSet: timelineSet, + timeline: timeline, }); // that won't make much difference, because we don't paginate