From 87b2cf9a1ea49adc8898b661d88a7659552d2981 Mon Sep 17 00:00:00 2001 From: Kerry Archibald Date: Mon, 2 May 2022 16:38:10 +0200 Subject: [PATCH 1/4] dont group beacon info with room creation summary Signed-off-by: Kerry Archibald --- src/components/structures/MessagePanel.tsx | 6 +++++ .../structures/MessagePanel-test.js | 27 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/src/components/structures/MessagePanel.tsx b/src/components/structures/MessagePanel.tsx index 38d18e92f76..289e0e5d4c8 100644 --- a/src/components/structures/MessagePanel.tsx +++ b/src/components/structures/MessagePanel.tsx @@ -23,6 +23,7 @@ import { MatrixEvent } from 'matrix-js-sdk/src/models/event'; import { Relations } from "matrix-js-sdk/src/models/relations"; import { logger } from 'matrix-js-sdk/src/logger'; import { RoomStateEvent } from "matrix-js-sdk/src/models/room-state"; +import { M_BEACON_INFO } from 'matrix-js-sdk/src/@types/beacon'; import shouldHideEvent from '../../shouldHideEvent'; import { wantsDateSeparator } from '../../DateUtils'; @@ -1098,9 +1099,13 @@ class CreationGrouper extends BaseGrouper { && (ev.getStateKey() !== createEvent.getSender() || ev.getContent()["membership"] !== "join")) { return false; } + if (M_BEACON_INFO.matches(ev.getType())) { + return false; + } if (ev.isState() && ev.getSender() === createEvent.getSender()) { return true; } + return false; } @@ -1174,6 +1179,7 @@ class CreationGrouper extends BaseGrouper { ret.push( ({ + useBeacon: jest.fn(), +})); let client; const room = new Matrix.Room("!roomId:server_name"); @@ -468,6 +473,7 @@ describe('MessagePanel', function() { // - all other events should be inside the room creation summary const tiles = res.find(UnwrappedEventTile); + // expect(tiles.map(tile => tile.props().mxEvent.getType())).toEqual([]) expect(tiles.at(0).props().mxEvent.getType()).toEqual("m.room.create"); expect(tiles.at(1).props().mxEvent.getType()).toEqual("m.room.encryption"); @@ -481,6 +487,27 @@ describe('MessagePanel', function() { expect(summaryEventTiles.length).toEqual(tiles.length - 3); }); + it('should not collapse beacons as part of creation events', function() { + const [creationEvent] = mkCreationEvents(); + const beaconInfoEvent = makeBeaconInfoEvent( + creationEvent.getSender(), + creationEvent.getRoomId(), + { isLive: true }, + ); + const combinedEvents = [creationEvent, beaconInfoEvent]; + TestUtilsMatrix.upsertRoomStateEvents(room, combinedEvents); + const res = mount( + , + ); + + const summaryTiles = res.find(GenericEventListSummary); + const summaryTile = summaryTiles.at(0); + + const summaryEventTiles = summaryTile.find(UnwrappedEventTile); + // nothing in the summary + expect(summaryEventTiles.length).toEqual(0); + }); + it('should hide read-marker at the end of creation event summary', function() { const events = mkCreationEvents(); TestUtilsMatrix.upsertRoomStateEvents(room, events); From b02ddeb4ba30090494e7e8228a1b5478d9a27ae1 Mon Sep 17 00:00:00 2001 From: Kerry Archibald Date: Mon, 2 May 2022 16:39:27 +0200 Subject: [PATCH 2/4] remove debugs Signed-off-by: Kerry Archibald --- src/components/structures/MessagePanel.tsx | 1 - test/components/structures/MessagePanel-test.js | 1 - 2 files changed, 2 deletions(-) diff --git a/src/components/structures/MessagePanel.tsx b/src/components/structures/MessagePanel.tsx index 289e0e5d4c8..916e11dca4d 100644 --- a/src/components/structures/MessagePanel.tsx +++ b/src/components/structures/MessagePanel.tsx @@ -1179,7 +1179,6 @@ class CreationGrouper extends BaseGrouper { ret.push( tile.props().mxEvent.getType())).toEqual([]) expect(tiles.at(0).props().mxEvent.getType()).toEqual("m.room.create"); expect(tiles.at(1).props().mxEvent.getType()).toEqual("m.room.encryption"); From 7bb86d26ad889c1c3bc26f8679434f7d02c64230 Mon Sep 17 00:00:00 2001 From: Kerry Archibald Date: Tue, 3 May 2022 10:18:57 +0200 Subject: [PATCH 3/4] add comment Signed-off-by: Kerry Archibald --- src/components/structures/MessagePanel.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/structures/MessagePanel.tsx b/src/components/structures/MessagePanel.tsx index 916e11dca4d..c8763c5d943 100644 --- a/src/components/structures/MessagePanel.tsx +++ b/src/components/structures/MessagePanel.tsx @@ -1099,6 +1099,8 @@ class CreationGrouper extends BaseGrouper { && (ev.getStateKey() !== createEvent.getSender() || ev.getContent()["membership"] !== "join")) { return false; } + // beacons are not part of room creation configuration + // should be shown in timeline if (M_BEACON_INFO.matches(ev.getType())) { return false; } From 4d9edda0a93a8dfdeab656350231e02786cd3520 Mon Sep 17 00:00:00 2001 From: Kerry Archibald Date: Tue, 3 May 2022 10:32:57 +0200 Subject: [PATCH 4/4] update comment Signed-off-by: Kerry Archibald --- src/components/structures/MessagePanel.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/structures/MessagePanel.tsx b/src/components/structures/MessagePanel.tsx index c8763c5d943..5dd5ea01936 100644 --- a/src/components/structures/MessagePanel.tsx +++ b/src/components/structures/MessagePanel.tsx @@ -1080,7 +1080,7 @@ abstract class BaseGrouper { // Wrap initial room creation events into a GenericEventListSummary // Grouping only events sent by the same user that sent the `m.room.create` and only until -// the first non-state event or membership event which is not regarding the sender of the `m.room.create` event +// the first non-state event, beacon_info event or membership event which is not regarding the sender of the `m.room.create` event class CreationGrouper extends BaseGrouper { static canStartGroup = function(panel: MessagePanel, ev: MatrixEvent): boolean { return ev.getType() === EventType.RoomCreate;