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

Don't show replaced calls in the timeline #7452

Merged
merged 7 commits into from
Jan 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/views/messages/CallEvent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,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 @@ -248,7 +248,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 @@ -1094,18 +1095,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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think what we'd actually want to do is merge the calls together so they appear as one long call, ie. take the start time as the time of the first call's invite and the hangup time as the ts of the other call's hangup event.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not really sure what you have in mind... If we're talking about the time, I believe that should be handled by the js-sdk when replacing the call probably. Though I am not really sure how to intelligently handle that for past calls though since both calls happen at a similar time I am not even sure if this is necessary.

Anyway, this feels like a different PR perhaps? Is there something else that should happen?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, as in we think this is already handled correctly by the js-sdk and we just have to display the right call and hide the other?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I don't think it's handled in the js-sdk but I would make that a separate change and I also don't think it is that big of a deal though I might be missing something here 😅

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 @@ -244,7 +244,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