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

Live location sharing - render message deleted tile for redacted beacons (PSF-1150) #8905

Merged
merged 1 commit into from
Jun 27, 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
6 changes: 5 additions & 1 deletion src/utils/beacon/timeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,9 @@ import { M_BEACON_INFO } from "matrix-js-sdk/src/@types/beacon";
*/
export const shouldDisplayAsBeaconTile = (event: MatrixEvent): boolean => (
M_BEACON_INFO.matches(event.getType()) &&
!!event.getContent()?.live
(
event.getContent()?.live ||
// redacted beacons should show 'message deleted' tile
event.isRedacted()
)
);
6 changes: 6 additions & 0 deletions test/utils/beacon/timeline-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,17 @@ describe('shouldDisplayAsBeaconTile', () => {
const liveBeacon = makeBeaconInfoEvent(userId, roomId, { isLive: true });
const notLiveBeacon = makeBeaconInfoEvent(userId, roomId, { isLive: false });
const memberEvent = new MatrixEvent({ type: EventType.RoomMember });
const redactedBeacon = makeBeaconInfoEvent(userId, roomId, { isLive: false });
redactedBeacon.makeRedacted(redactedBeacon);

it('returns true for a beacon with live property set to true', () => {
expect(shouldDisplayAsBeaconTile(liveBeacon)).toBe(true);
});

it('returns true for a redacted beacon', () => {
expect(shouldDisplayAsBeaconTile(redactedBeacon)).toBe(true);
});

it('returns false for a beacon with live property set to false', () => {
expect(shouldDisplayAsBeaconTile(notLiveBeacon)).toBe(false);
});
Expand Down