Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Live location sharing - don't trigger unread counts for beacon location events #9071

Merged
merged 1 commit into from
Jul 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Unread.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
}

Expand Down
8 changes: 7 additions & 1 deletion test/Unread-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => ({
Expand Down Expand Up @@ -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,
Expand Down