update to use new API based on js-sdk PR input
This commit is contained in:
parent
3c7864a7ad
commit
4aef352a5c
6 changed files with 16 additions and 8 deletions
|
@ -107,7 +107,7 @@ class MatrixClientPeg {
|
||||||
|
|
||||||
this.matrixClient.setGuest(Boolean(creds.guest));
|
this.matrixClient.setGuest(Boolean(creds.guest));
|
||||||
|
|
||||||
var notifTimelineSet = new EventTimelineSet(null, null, {
|
var notifTimelineSet = new EventTimelineSet(null, {
|
||||||
timelineSupport: true
|
timelineSupport: true
|
||||||
});
|
});
|
||||||
// XXX: what is our initial pagination token?! it somehow needs to be synchronised with /sync.
|
// XXX: what is our initial pagination token?! it somehow needs to be synchronised with /sync.
|
||||||
|
|
|
@ -224,10 +224,11 @@ var Notifier = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onRoomTimeline: function(ev, room, toStartOfTimeline) {
|
onRoomTimeline: function(ev, room, toStartOfTimeline, removed, data) {
|
||||||
if (toStartOfTimeline) return;
|
if (toStartOfTimeline) return;
|
||||||
if (!this.isPrepared) return; // don't alert for any messages initially
|
if (!this.isPrepared) return; // don't alert for any messages initially
|
||||||
if (ev.sender && ev.sender.userId == MatrixClientPeg.get().credentials.userId) return;
|
if (ev.sender && ev.sender.userId == MatrixClientPeg.get().credentials.userId) return;
|
||||||
|
if (data.timeline.getTimelineSet() !== room.getUnfilteredTimelineSet()) return;
|
||||||
|
|
||||||
var actions = MatrixClientPeg.get().getPushActionsForEvent(ev);
|
var actions = MatrixClientPeg.get().getPushActionsForEvent(ev);
|
||||||
if (actions && actions.notify) {
|
if (actions && actions.notify) {
|
||||||
|
|
|
@ -342,6 +342,9 @@ module.exports = React.createClass({
|
||||||
// ignore events for other rooms
|
// ignore events for other rooms
|
||||||
if (!this.state.room || room.roomId != this.state.room.roomId) return;
|
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") {
|
if (ev.getType() === "org.matrix.room.preview_urls") {
|
||||||
this._updatePreviewUrlVisibility(room);
|
this._updatePreviewUrlVisibility(room);
|
||||||
}
|
}
|
||||||
|
|
|
@ -320,8 +320,8 @@ var TimelinePanel = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
onRoomTimeline: function(ev, room, toStartOfTimeline, removed, data) {
|
onRoomTimeline: function(ev, room, toStartOfTimeline, removed, data) {
|
||||||
// ignore events for other rooms
|
// ignore events for other timeline sets
|
||||||
if (data.timelineSet !== this.props.timelineSet) return;
|
if (data.timeline.getTimelineSet() !== this.props.timelineSet) return;
|
||||||
|
|
||||||
// ignore anything but real-time updates at the end of the room:
|
// ignore anything but real-time updates at the end of the room:
|
||||||
// updates from pagination will happen when the paginate completes.
|
// updates from pagination will happen when the paginate completes.
|
||||||
|
|
|
@ -146,8 +146,9 @@ module.exports = React.createClass({
|
||||||
this._updateStickyHeaders(true, scrollToPosition);
|
this._updateStickyHeaders(true, scrollToPosition);
|
||||||
},
|
},
|
||||||
|
|
||||||
onRoomTimeline: function(ev, room, toStartOfTimeline) {
|
onRoomTimeline: function(ev, room, toStartOfTimeline, removed, data) {
|
||||||
if (toStartOfTimeline) return;
|
if (toStartOfTimeline) return;
|
||||||
|
if (data.timeline.getTimelineSet() !== room.getUnfilteredTimelineSet()) return;
|
||||||
this._delayedRefreshRoomList();
|
this._delayedRefreshRoomList();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -59,14 +59,17 @@ describe('TimelinePanel', function() {
|
||||||
test_utils.beforeEach(this);
|
test_utils.beforeEach(this);
|
||||||
sandbox = test_utils.stubClient(sandbox);
|
sandbox = test_utils.stubClient(sandbox);
|
||||||
|
|
||||||
timeline = new jssdk.EventTimeline(ROOM_ID);
|
|
||||||
room = sinon.createStubInstance(jssdk.Room);
|
room = sinon.createStubInstance(jssdk.Room);
|
||||||
|
room.roomId = ROOM_ID;
|
||||||
|
|
||||||
timelineSet = sinon.createStubInstance(jssdk.EventTimelineSet);
|
timelineSet = sinon.createStubInstance(jssdk.EventTimelineSet);
|
||||||
timelineSet.getLiveTimeline.returns(timeline);
|
|
||||||
timelineSet.getPendingEvents.returns([]);
|
timelineSet.getPendingEvents.returns([]);
|
||||||
timelineSet.room = room;
|
timelineSet.room = room;
|
||||||
|
|
||||||
|
timeline = new jssdk.EventTimeline(timelineSet);
|
||||||
|
|
||||||
|
timelineSet.getLiveTimeline.returns(timeline);
|
||||||
|
|
||||||
client = peg.get();
|
client = peg.get();
|
||||||
client.credentials = {userId: USER_ID};
|
client.credentials = {userId: USER_ID};
|
||||||
|
|
||||||
|
@ -149,7 +152,7 @@ describe('TimelinePanel', function() {
|
||||||
timeline.addEvent(ev);
|
timeline.addEvent(ev);
|
||||||
panel.onRoomTimeline(ev, room, false, false, {
|
panel.onRoomTimeline(ev, room, false, false, {
|
||||||
liveEvent: true,
|
liveEvent: true,
|
||||||
timelineSet: timelineSet,
|
timeline: timeline,
|
||||||
});
|
});
|
||||||
|
|
||||||
// that won't make much difference, because we don't paginate
|
// that won't make much difference, because we don't paginate
|
||||||
|
|
Loading…
Reference in a new issue