From 36d0dacda180f1002b34a75c585a9849d508f2b4 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Wed, 10 Jul 2019 10:26:21 -0600 Subject: [PATCH 1/3] Process ephemeral events outside timeline handling --- spec/unit/room.spec.js | 2 +- src/models/room.js | 29 +++++++++++++++++------------ src/sync.js | 6 ++---- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/spec/unit/room.spec.js b/spec/unit/room.spec.js index a809dd6ee..b257ec637 100644 --- a/spec/unit/room.spec.js +++ b/spec/unit/room.spec.js @@ -104,7 +104,7 @@ describe("Room", function() { user_ids: [userA], }, }); - room.addLiveEvents([typing]); + room.addEphemeralEvents([typing]); expect(room.currentState.setTypingEvent).toHaveBeenCalledWith(typing); }); diff --git a/src/models/room.js b/src/models/room.js index 3969ede4c..057686936 100644 --- a/src/models/room.js +++ b/src/models/room.js @@ -1402,18 +1402,23 @@ Room.prototype.addLiveEvents = function(events, duplicateStrategy) { } for (i = 0; i < events.length; i++) { - if (events[i].getType() === "m.typing") { - this.currentState.setTypingEvent(events[i]); - } else if (events[i].getType() === "m.receipt") { - this.addReceipt(events[i]); - } - // N.B. account_data is added directly by /sync to avoid - // having to maintain an event.isAccountData() here - else { - // TODO: We should have a filter to say "only add state event - // types X Y Z to the timeline". - this._addLiveEvent(events[i], duplicateStrategy); - } + // TODO: We should have a filter to say "only add state event + // types X Y Z to the timeline". + this._addLiveEvent(events[i], duplicateStrategy); + } +}; + +/** + * Adds/handles ephemeral events such as typing notifications and read receipts. + * @param {MatrixEvent[]} events A list of events to process + */ +Room.prototype.addEphemeralEvents = function(events) { + for (const event of events) { + if (event.getType() === 'm.typing') { + this.currentState.setTypingEvent(event); + } else if (event.getType() === 'm.receipt') { + this.addReceipt(event); + } // else ignore - life is too short for us to care about these events } }; diff --git a/src/sync.js b/src/sync.js index 106e4e2fc..12775903e 100644 --- a/src/sync.js +++ b/src/sync.js @@ -1245,10 +1245,8 @@ SyncApi.prototype._processSyncResponse = async function( room.setSummary(joinObj.summary); } - // XXX: should we be adding ephemeralEvents to the timeline? - // It feels like that for symmetry with room.addAccountData() - // there should be a room.addEphemeralEvents() or similar. - room.addLiveEvents(ephemeralEvents); + // we deliberately don't add ephemeral events to the timeline + room.addEphemeralEvents(ephemeralEvents); // we deliberately don't add accountData to the timeline room.addAccountData(accountDataEvents); From 0edb6e6f6f4876afd8653e1b492c7de396aa5923 Mon Sep 17 00:00:00 2001 From: RiotRobot Date: Thu, 11 Jul 2019 10:34:58 +0100 Subject: [PATCH 2/3] Prepare changelog for v2.1.1 --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 889efbcb6..07b42b620 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +Changes in [2.1.1](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v2.1.1) (2019-07-11) +================================================================================================ +[Full Changelog](https://github.com/matrix-org/matrix-js-sdk/compare/v2.1.0...v2.1.1) + + * Process emphemeral events outside timeline handling + [\#989](https://github.com/matrix-org/matrix-js-sdk/pull/989) + Changes in [2.1.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v2.1.0) (2019-07-08) ================================================================================================ [Full Changelog](https://github.com/matrix-org/matrix-js-sdk/compare/v2.1.0-rc.1...v2.1.0) From 50c14d0ab890472db6d0dd21cc8ebca9f6b3c0dc Mon Sep 17 00:00:00 2001 From: RiotRobot Date: Thu, 11 Jul 2019 10:34:58 +0100 Subject: [PATCH 3/3] v2.1.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7f1539b12..fa386a7ab 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "matrix-js-sdk", - "version": "2.1.0", + "version": "2.1.1", "description": "Matrix Client-Server SDK for Javascript", "main": "index.js", "scripts": {