@@ -6,10 +6,11 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Com
66Please see LICENSE files in the repository root for full details.
77 */
88
9- import { type MatrixEvent , EventType , RelationType , M_POLL_END } from "matrix-js-sdk/src/matrix" ;
9+ import { type MatrixEvent , EventType , RelationType , JoinRule , M_POLL_END } from "matrix-js-sdk/src/matrix" ;
1010import { KnownMembership } from "matrix-js-sdk/src/types" ;
1111
1212import SettingsStore from "./settings/SettingsStore" ;
13+ import MatrixClientPeg from "./MatrixClientPeg" ;
1314import { type IRoomState } from "./components/structures/RoomView" ;
1415import { type SettingKey } from "./settings/Settings.tsx" ;
1516
@@ -43,6 +44,11 @@ function memberEventDiff(ev: MatrixEvent): IDiff {
4344 return diff ;
4445}
4546
47+ function isPublicRoom ( ev : MatrixEvent ) : boolean {
48+ const room = MatrixClientPeg . get ( ) . getRoom ( ev . getRoomId ( ) ) ;
49+ return room ?. getJoinRule ( ) === JoinRule . Public ;
50+ }
51+
4652/**
4753 * Determines whether the given event should be hidden from timelines.
4854 * @param ev The event
@@ -53,6 +59,8 @@ export default function shouldHideEvent(ev: MatrixEvent, ctx?: IRoomState): bool
5359 // Hide all poll end events
5460 if ( M_POLL_END . matches ( ev . getType ( ) ) ) return true ;
5561
62+ if ( ev . getType ( ) === EventType . RoomTopic && isPublicRoom ( ev ) ) return true ;
63+
5664 // Accessing the settings store directly can be expensive if done frequently,
5765 // so we should prefer using cached values if a RoomContext is available
5866 const isEnabled = ctx
@@ -70,6 +78,8 @@ export default function shouldHideEvent(ev: MatrixEvent, ctx?: IRoomState): bool
7078 const eventDiff = memberEventDiff ( ev ) ;
7179
7280 if ( eventDiff . isMemberEvent ) {
81+ if ( isPublicRoom ( ev ) ) return true ;
82+
7383 if ( ( eventDiff . isJoin || eventDiff . isPart ) && ! isEnabled ( "showJoinLeaves" ) ) return true ;
7484 if ( eventDiff . isAvatarChange && ! isEnabled ( "showAvatarChanges" ) ) return true ;
7585 if ( eventDiff . isDisplaynameChange && ! isEnabled ( "showDisplaynameChanges" ) ) return true ;
0 commit comments