From 8d70f5aab3f9af67d93f065f1211b81d70dbac69 Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Sun, 3 Sep 2023 09:58:04 +1200 Subject: [PATCH] Change event to chat.schildi.hide_ui->read_receipts --- src/components/structures/RoomView.tsx | 25 +++++++++++++------------ src/contexts/RoomContext.ts | 1 + test/test-utils/room.ts | 1 + 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/components/structures/RoomView.tsx b/src/components/structures/RoomView.tsx index 04a5d2371ec..3ef7f398e67 100644 --- a/src/components/structures/RoomView.tsx +++ b/src/components/structures/RoomView.tsx @@ -214,9 +214,7 @@ export interface IRoomState { readMarkerOutOfViewThresholdMs: number; showHiddenEvents: boolean; showReadReceipts: boolean; - preferHidden: { - read_receipts: boolean; - } + schildichatHideUIReadReceipts: boolean; showRedactions: boolean; showJoinLeaves: boolean; showAvatarChanges: boolean; @@ -432,9 +430,7 @@ export class RoomView extends React.Component { readMarkerOutOfViewThresholdMs: SettingsStore.getValue("readMarkerOutOfViewThresholdMs"), showHiddenEvents: SettingsStore.getValue("showHiddenEventsInTimeline"), showReadReceipts: true, - preferHidden: { - read_receipts: false - }, + schildichatHideUIReadReceipts: false, showRedactions: true, showJoinLeaves: true, showAvatarChanges: true, @@ -668,9 +664,10 @@ export class RoomView extends React.Component { activeCall: CallStore.instance.getActiveCall(roomId), }; - newState.preferHidden = room?.getLiveTimeline().getState(EventTimeline.FORWARDS).getStateEvents("chat.schildi.prefer_hidden", "")?.getContent() || { - read_receipts: false - } + newState.schildichatHideUIReadReceipts = + room?.getLiveTimeline().getState(EventTimeline.FORWARDS) + .getStateEvents("chat.schildi.hide_ui", "read_receipts")?.getContent()?.hidden + || false; if ( this.state.mainSplitContentType !== MainSplitContentType.Timeline && @@ -1544,8 +1541,12 @@ export class RoomView extends React.Component { this.setState({ tombstone: this.getRoomTombstone() }); break; - case "chat.schildi.prefer_hidden": - this.setState({ preferHidden: ev.getContent() }) + case "chat.schildi.hide_ui": + switch (ev.getStateKey()) { + case "read_receipts": + this.setState({ schildichatHideUIReadReceipts: ev.getContent()?.hidden }) + break; + } break; default: @@ -2410,7 +2411,7 @@ export class RoomView extends React.Component { timelineSet={this.state.room.getUnfilteredTimelineSet()} overlayTimelineSet={this.state.virtualRoom?.getUnfilteredTimelineSet()} overlayTimelineSetFilter={isCallEvent} - showReadReceipts={this.state.showReadReceipts && !this.state.preferHidden.read_receipts} + showReadReceipts={this.state.showReadReceipts && !this.state.schildichatHideUIReadReceipts} manageReadReceipts={!this.state.isPeeking} sendReadReceiptOnLoad={!this.state.wasContextSwitch} manageReadMarkers={!this.state.isPeeking} diff --git a/src/contexts/RoomContext.ts b/src/contexts/RoomContext.ts index 63d3049e803..059d788cebf 100644 --- a/src/contexts/RoomContext.ts +++ b/src/contexts/RoomContext.ts @@ -58,6 +58,7 @@ const RoomContext = createContext({ readMarkerOutOfViewThresholdMs: 30000, showHiddenEvents: false, showReadReceipts: true, + schildichatHideUIReadReceipts: false, showRedactions: true, showJoinLeaves: true, showAvatarChanges: true, diff --git a/test/test-utils/room.ts b/test/test-utils/room.ts index 46d18309ab4..28ec229965c 100644 --- a/test/test-utils/room.ts +++ b/test/test-utils/room.ts @@ -79,6 +79,7 @@ export function getRoomContext(room: Room, override: Partial): IRoom readMarkerOutOfViewThresholdMs: 30000, showHiddenEvents: false, showReadReceipts: true, + schildichatHideUIReadReceipts: false, showRedactions: true, showJoinLeaves: true, showAvatarChanges: true,