From e08ad4ab96a85249069def44868ecfd89e81abbf Mon Sep 17 00:00:00 2001 From: Kerry Archibald Date: Mon, 18 Jul 2022 13:23:59 +0200 Subject: [PATCH] dont trigger unread counts for beacon location events --- src/Unread.ts | 3 +++ test/Unread-test.ts | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Unread.ts b/src/Unread.ts index 7deafef9678..19dc07f4141 100644 --- a/src/Unread.ts +++ b/src/Unread.ts @@ -17,6 +17,7 @@ limitations under the License. import { Room } from "matrix-js-sdk/src/models/room"; import { MatrixEvent } from "matrix-js-sdk/src/models/event"; import { EventType } from "matrix-js-sdk/src/@types/event"; +import { M_BEACON } from "matrix-js-sdk/src/@types/beacon"; import { MatrixClientPeg } from "./MatrixClientPeg"; import shouldHideEvent from './shouldHideEvent'; @@ -44,6 +45,8 @@ export function eventTriggersUnreadCount(ev: MatrixEvent): boolean { case EventType.RoomAliases: case EventType.RoomCanonicalAlias: case EventType.RoomServerAcl: + case M_BEACON.name: + case M_BEACON.altName: return false; } diff --git a/test/Unread-test.ts b/test/Unread-test.ts index 836a3432351..1c1c469cba1 100644 --- a/test/Unread-test.ts +++ b/test/Unread-test.ts @@ -22,7 +22,7 @@ import { } from "matrix-js-sdk/src/matrix"; import { haveRendererForEvent } from "../src/events/EventTileFactory"; -import { getMockClientWithEventEmitter, mockClientMethodsUser } from "./test-utils"; +import { getMockClientWithEventEmitter, makeBeaconEvent, mockClientMethodsUser } from "./test-utils"; import { eventTriggersUnreadCount } from "../src/Unread"; jest.mock("../src/events/EventTileFactory", () => ({ @@ -92,6 +92,12 @@ describe('eventTriggersUnreadCount()', () => { expect(haveRendererForEvent).toHaveBeenCalledWith(alicesMessage, false); }); + it('returns false for beacon locations', () => { + const beaconLocationEvent = makeBeaconEvent(aliceId); + expect(eventTriggersUnreadCount(beaconLocationEvent)).toBe(false); + expect(haveRendererForEvent).not.toHaveBeenCalled(); + }); + const noUnreadEventTypes = [ EventType.RoomMember, EventType.RoomThirdPartyInvite,