diff --git a/src/components/structures/RoomView.tsx b/src/components/structures/RoomView.tsx index 486a7fb6521..06ae1b5a3aa 100644 --- a/src/components/structures/RoomView.tsx +++ b/src/components/structures/RoomView.tsx @@ -217,6 +217,7 @@ export interface IRoomState { showReadReceipts: boolean; showRedactions: boolean; showJoinLeaves: boolean; + showInvites: boolean; showAvatarChanges: boolean; showDisplaynameChanges: boolean; matrixClientIsReady: boolean; @@ -406,6 +407,7 @@ export class RoomView extends React.Component { showReadReceipts: true, showRedactions: true, showJoinLeaves: true, + showInvites: true, showAvatarChanges: true, showDisplaynameChanges: true, matrixClientIsReady: context.client?.isInitialSyncComplete(), @@ -608,6 +610,7 @@ export class RoomView extends React.Component { showReadReceipts: SettingsStore.getValue("showReadReceipts", roomId), showRedactions: SettingsStore.getValue("showRedactions", roomId), showJoinLeaves: SettingsStore.getValue("showJoinLeaves", roomId), + showInvites: SettingsStore.getValue("showInvites", roomId), showAvatarChanges: SettingsStore.getValue("showAvatarChanges", roomId), showDisplaynameChanges: SettingsStore.getValue("showDisplaynameChanges", roomId), wasContextSwitch: this.context.roomViewStore.getWasContextSwitch(), @@ -679,6 +682,9 @@ export class RoomView extends React.Component { SettingsStore.watchSetting("showJoinLeaves", roomId, (...[, , , value]) => this.setState({ showJoinLeaves: value as boolean }), ), + SettingsStore.watchSetting("showInvites", roomId, (...[, , , value]) => + this.setState({ showInvites: value as boolean }), + ), SettingsStore.watchSetting("showAvatarChanges", roomId, (...[, , , value]) => this.setState({ showAvatarChanges: value as boolean }), ), diff --git a/src/components/views/settings/tabs/user/PreferencesUserSettingsTab.tsx b/src/components/views/settings/tabs/user/PreferencesUserSettingsTab.tsx index d95b0894d9b..1c33c4ed36f 100644 --- a/src/components/views/settings/tabs/user/PreferencesUserSettingsTab.tsx +++ b/src/components/views/settings/tabs/user/PreferencesUserSettingsTab.tsx @@ -150,6 +150,7 @@ export default class PreferencesUserSettingsTab extends React.Component): IRoom showReadReceipts: true, showRedactions: true, showJoinLeaves: true, + showInvites: true, showAvatarChanges: true, showDisplaynameChanges: true, matrixClientIsReady: false, diff --git a/test/unit-tests/components/structures/MessagePanel-test.tsx b/test/unit-tests/components/structures/MessagePanel-test.tsx index 037a57bb061..d0f43fbe826 100644 --- a/test/unit-tests/components/structures/MessagePanel-test.tsx +++ b/test/unit-tests/components/structures/MessagePanel-test.tsx @@ -82,6 +82,7 @@ describe("MessagePanel", function () { showReadReceipts: true, showRedactions: false, showJoinLeaves: false, + showInvites: true, showAvatarChanges: false, showDisplaynameChanges: true, showHiddenEvents: false, @@ -463,6 +464,34 @@ describe("MessagePanel", function () { expect(summaryEventTiles.length).toEqual(tiles.length - 3); }); + it("shows invite events if the user wishes to see them", function () { + const events = mkCreationEvents(); + const inviteEvent = events.find( + (event) => + event.getType() === "m.room.member" + && event.getContent()?.membership === "invite" + )!; + const { container } = render(getComponent({ events }, { showInvites: true })); + + // there must be an invite event + const inviteEventTiles = container.querySelectorAll(`.mx_EventTile[data-event-id=\"${inviteEvent.getId()}\"]`); + expect(inviteEventTiles.length).toBeGreaterThan(0); + }); + + it("hides invite events if the user does not wish to see them", function () { + const events = mkCreationEvents(); + const inviteEvent = events.find( + (event) => + event.getType() === "m.room.member" + && event.getContent()?.membership === "invite" + )!; + const { container } = render(getComponent({ events }, { showInvites: false })); + + // our invite event must not exist + const inviteEventTiles = container.querySelectorAll(`.mx_EventTile[data-event-id=\"${inviteEvent.getId()}\"]`); + expect(inviteEventTiles.length).toBe(0); + }); + it("should not collapse beacons as part of creation events", function () { const events = mkCreationEvents(); const creationEvent = events.find((event) => event.getType() === "m.room.create")!; diff --git a/test/unit-tests/components/views/rooms/SendMessageComposer-test.tsx b/test/unit-tests/components/views/rooms/SendMessageComposer-test.tsx index a41c221616a..9a4607b960d 100644 --- a/test/unit-tests/components/views/rooms/SendMessageComposer-test.tsx +++ b/test/unit-tests/components/views/rooms/SendMessageComposer-test.tsx @@ -64,6 +64,7 @@ describe("", () => { showReadReceipts: true, showRedactions: true, showJoinLeaves: true, + showInvites: true, showAvatarChanges: true, showDisplaynameChanges: true, matrixClientIsReady: false,