diff --git a/.changeset/hide-reactions-redactions-read-only.md b/.changeset/hide-reactions-redactions-read-only.md new file mode 100644 index 000000000..1ecab466e --- /dev/null +++ b/.changeset/hide-reactions-redactions-read-only.md @@ -0,0 +1,5 @@ +--- +default: patch +--- + +Hide membership events in read only rooms now also hides reactions and reaction redactions. diff --git a/src/app/features/settings/general/General.tsx b/src/app/features/settings/general/General.tsx index 4ff9596f5..7d5c7bbd4 100644 --- a/src/app/features/settings/general/General.tsx +++ b/src/app/features/settings/general/General.tsx @@ -1021,6 +1021,7 @@ function Messages() { , hiddenEventReactions: boolean, hiddenEventReactionTombstone: boolean, + hideMemberInReadOnly: boolean, + isReadOnly: boolean, mxUserId: string | null, readUptoEventId: string | undefined ): ProcessedEvent[] => { + if (hideMemberInReadOnly && isReadOnly) return result; + const existingIds = new Set(result.map((event) => event.id)); const extras = collectRelationReactionEvents( linkedTimelines, @@ -273,6 +279,16 @@ export function useProcessedTimeline({ const isReaction = isReactionEvent(mEvent); const isRedactionEvt = mEvent.isRedaction(); + if (hideMemberInReadOnly && isReadOnly) { + if (isReaction) return acc; + if ( + isRedactionEvt && + getRedactionTargetEvent(timelineSet, mEvent)?.getType() === (EventType.Reaction as string) + ) { + return acc; + } + } + if (mEvent.isRedacted()) { const showMessageTombstone = showTombstoneEvents && isRedactableMessageType(type); const showReactionTombstone = hiddenEventReactionTombstone && isReaction; @@ -409,6 +425,8 @@ export function useProcessedTimeline({ ignoredUsersSet, hiddenEventReactions, hiddenEventReactionTombstone, + hideMemberInReadOnly, + isReadOnly, mxUserId, readUptoEventId ), diff --git a/src/app/hooks/timeline/useTimelineEventRenderer.tsx b/src/app/hooks/timeline/useTimelineEventRenderer.tsx index 7b952a323..2b8a7f3aa 100644 --- a/src/app/hooks/timeline/useTimelineEventRenderer.tsx +++ b/src/app/hooks/timeline/useTimelineEventRenderer.tsx @@ -1367,6 +1367,8 @@ export function useTimelineEventRenderer({ ); }, [EventType.Reaction]: (mEventId, mEvent, item, timelineSet, collapse) => { + if (hideMemberInReadOnly && isReadOnly) return null; + const highlighted = focusItem?.index === item && focusItem.highlight; const marked = activeReplyId === mEventId; const senderId = mEvent.getSender() ?? ''; @@ -1485,6 +1487,7 @@ export function useTimelineEventRenderer({ const target = getRedactionTargetEvent(timelineSet, mEvent); const isReactionRedaction = target?.getType() === (EventType.Reaction as string); if (isReactionRedaction) { + if (hideMemberInReadOnly && isReadOnly) return null; if (!hiddenEventReactionRedactionTimeline) return null; } else if (!hiddenEventRedactionTimeline) { return null;