Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Don't show replaced calls in the timeline (#7452)
Browse files Browse the repository at this point in the history
* Don't show replaced calls in the timeline

Signed-off-by: Šimon Brandner <[email protected]>

* Revert changes to CallEvent

Signed-off-by: Šimon Brandner <[email protected]>

* Add option to force hide event

Signed-off-by: Šimon Brandner <[email protected]>

* Hide replaced calls

Signed-off-by: Šimon Brandner <[email protected]>
  • Loading branch information
SimonBrandner authored Jan 31, 2022
1 parent 991257c commit a55482b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/components/views/messages/CallEvent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default class CallEvent extends React.PureComponent<IProps, IState> {
this.props.callEventGrouper.addListener(CallEventGrouperEvent.LengthChanged, this.onLengthChanged);

this.resizeObserver = new ResizeObserver(this.resizeObserverCallback);
this.resizeObserver.observe(this.wrapperElement.current);
this.wrapperElement.current && this.resizeObserver.observe(this.wrapperElement.current);
}

componentWillUnmount() {
Expand Down Expand Up @@ -258,7 +258,7 @@ export default class CallEvent extends React.PureComponent<IProps, IState> {
);
}

render() {
public render(): JSX.Element {
const event = this.props.mxEvent;
const sender = event.sender ? event.sender.name : event.getSender();
const isVoice = this.props.callEventGrouper.isVoice;
Expand Down
16 changes: 14 additions & 2 deletions src/components/views/rooms/EventTile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { RoomMember } from "matrix-js-sdk/src/models/room-member";
import { Thread, ThreadEvent } from 'matrix-js-sdk/src/models/thread';
import { logger } from "matrix-js-sdk/src/logger";
import { NotificationCountType, Room } from 'matrix-js-sdk/src/models/room';
import { CallErrorCode } from "matrix-js-sdk/src/webrtc/call";
import { M_POLL_START } from "matrix-events-sdk";

import ReplyChain from "../elements/ReplyChain";
Expand Down Expand Up @@ -1097,18 +1098,29 @@ export default class EventTile extends React.Component<IProps, IState> {
});
};

/**
* In some cases we can't use shouldHideEvent() since whether or not we hide
* an event depends on other things that the event itself
* @returns {boolean} true if event should be hidden
*/
private shouldHideEvent(): boolean {
// If the call was replaced we don't render anything since we render the other call
if (this.props.callEventGrouper?.hangupReason === CallErrorCode.Replaced) return true;

return false;
}

render() {
const msgtype = this.props.mxEvent.getContent().msgtype;
const eventType = this.props.mxEvent.getType() as EventType;
const eventDisplayInfo = getEventDisplayInfo(this.props.mxEvent);
const {
tileHandler,
isBubbleMessage,
isInfoMessage,
isLeftAlignedBubbleMessage,
noBubbleEvent,
isSeeingThroughMessageHiddenForModeration,
} = eventDisplayInfo;
} = getEventDisplayInfo(this.props.mxEvent, this.shouldHideEvent());
const { isQuoteExpanded } = this.state;

// This shouldn't happen: the caller should check we support this type
Expand Down
4 changes: 2 additions & 2 deletions src/utils/EventUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export function getMessageModerationState(mxEvent: MatrixEvent): MessageModerati
return MessageModerationState.HIDDEN_TO_CURRENT_USER;
}

export function getEventDisplayInfo(mxEvent: MatrixEvent): {
export function getEventDisplayInfo(mxEvent: MatrixEvent, hideEvent?: boolean): {
isInfoMessage: boolean;
tileHandler: string;
isBubbleMessage: boolean;
Expand Down Expand Up @@ -245,7 +245,7 @@ export function getEventDisplayInfo(mxEvent: MatrixEvent): {
// source tile when there's no regular tile for an event and also for
// replace relations (which otherwise would display as a confusing
// duplicate of the thing they are replacing).
if (SettingsStore.getValue("showHiddenEventsInTimeline") && !haveTileForEvent(mxEvent)) {
if ((hideEvent || !haveTileForEvent(mxEvent)) && SettingsStore.getValue("showHiddenEventsInTimeline")) {
tileHandler = "messages.ViewSourceEvent";
isBubbleMessage = false;
// Reuse info message avatar and sender profile styling
Expand Down

0 comments on commit a55482b

Please sign in to comment.