diff --git a/src/components/structures/RoomView.tsx b/src/components/structures/RoomView.tsx index 486a7fb6521..404b8fa67ee 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; + showInviteKicks: boolean; showAvatarChanges: boolean; showDisplaynameChanges: boolean; matrixClientIsReady: boolean; @@ -406,6 +407,7 @@ export class RoomView extends React.Component { showReadReceipts: true, showRedactions: true, showJoinLeaves: true, + showInviteKicks: 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), + showInviteKicks: SettingsStore.getValue("showInviteKicks", 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("showInviteKicks", roomId, (...[, , , value]) => + this.setState({ showInviteKicks: 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..bdc5dc70678 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, + showInviteKicks: 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..6604ad75102 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, + showInviteKicks: 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 }, { showInviteKicks: 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 }, { showInviteKicks: 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..c625d1f6710 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, + showInviteKicks: true, showAvatarChanges: true, showDisplaynameChanges: true, matrixClientIsReady: false,