Skip to content

Commit

Permalink
Change event to chat.schildi.hide_ui->read_receipts
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudrac3r committed Sep 2, 2023
1 parent af709e4 commit 8d70f5a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/components/structures/RoomView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -432,9 +430,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
readMarkerOutOfViewThresholdMs: SettingsStore.getValue("readMarkerOutOfViewThresholdMs"),
showHiddenEvents: SettingsStore.getValue("showHiddenEventsInTimeline"),
showReadReceipts: true,
preferHidden: {
read_receipts: false
},
schildichatHideUIReadReceipts: false,
showRedactions: true,
showJoinLeaves: true,
showAvatarChanges: true,
Expand Down Expand Up @@ -668,9 +664,10 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
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)

Check failure on line 668 in src/components/structures/RoomView.tsx

View workflow job for this annotation

GitHub Actions / Typescript Strict Error Checker (--strict --noImplicitAny)

Object is possibly 'undefined'.

src/components/structures/RoomView.tsx:668:13 - Object is possibly 'undefined'.
.getStateEvents("chat.schildi.hide_ui", "read_receipts")?.getContent()?.hidden
|| false;

if (
this.state.mainSplitContentType !== MainSplitContentType.Timeline &&
Expand Down Expand Up @@ -1544,8 +1541,12 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
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:
Expand Down Expand Up @@ -2410,7 +2411,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
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}
Expand Down
1 change: 1 addition & 0 deletions src/contexts/RoomContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const RoomContext = createContext<IRoomState>({
readMarkerOutOfViewThresholdMs: 30000,
showHiddenEvents: false,
showReadReceipts: true,
schildichatHideUIReadReceipts: false,
showRedactions: true,
showJoinLeaves: true,
showAvatarChanges: true,
Expand Down
1 change: 1 addition & 0 deletions test/test-utils/room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export function getRoomContext(room: Room, override: Partial<IRoomState>): IRoom
readMarkerOutOfViewThresholdMs: 30000,
showHiddenEvents: false,
showReadReceipts: true,
schildichatHideUIReadReceipts: false,
showRedactions: true,
showJoinLeaves: true,
showAvatarChanges: true,
Expand Down

0 comments on commit 8d70f5a

Please sign in to comment.