Ensure consistency when rendering the sent event indicator (#11314)
* Ensure consistency when considering where to render the sent event indicator * Add test * Fix redacted edge case * Comments
This commit is contained in:
parent
5fbdbccdc6
commit
b5cbd9eeca
3 changed files with 146 additions and 107 deletions
|
@ -246,6 +246,24 @@ interface IState {
|
|||
threadNotification?: NotificationCountType;
|
||||
}
|
||||
|
||||
/**
|
||||
* When true, the tile qualifies for some sort of special read receipt.
|
||||
* This could be a 'sending' or 'sent' receipt, for example.
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export function isEligibleForSpecialReceipt(event: MatrixEvent, myUserId: string): boolean {
|
||||
// Check to see if the event was sent by us. If it wasn't, it won't qualify for special read receipts.
|
||||
if (event.getSender() !== myUserId) return false;
|
||||
|
||||
// Determine if the type is relevant to the user.
|
||||
// This notably excludes state events and pretty much anything that can't be sent by the composer as a message.
|
||||
// For those we rely on local echo giving the impression of things changing, and expect them to be quick.
|
||||
if (!isMessageEvent(event) && event.getType() !== EventType.RoomMessageEncrypted) return false;
|
||||
|
||||
// Default case
|
||||
return true;
|
||||
}
|
||||
|
||||
// MUST be rendered within a RoomContext with a set timelineRenderingType
|
||||
export class UnwrappedEventTile extends React.Component<EventTileProps, IState> {
|
||||
private suppressReadReceiptAnimation: boolean;
|
||||
|
@ -313,23 +331,8 @@ export class UnwrappedEventTile extends React.Component<EventTileProps, IState>
|
|||
|
||||
// Quickly check to see if the event was sent by us. If it wasn't, it won't qualify for
|
||||
// special read receipts.
|
||||
const myUserId = MatrixClientPeg.safeGet().getUserId();
|
||||
if (this.props.mxEvent.getSender() !== myUserId) return false;
|
||||
|
||||
// Finally, determine if the type is relevant to the user. This notably excludes state
|
||||
// events and pretty much anything that can't be sent by the composer as a message. For
|
||||
// those we rely on local echo giving the impression of things changing, and expect them
|
||||
// to be quick.
|
||||
const simpleSendableEvents = [
|
||||
EventType.Sticker,
|
||||
EventType.RoomMessage,
|
||||
EventType.RoomMessageEncrypted,
|
||||
EventType.PollStart,
|
||||
];
|
||||
if (!simpleSendableEvents.includes(this.props.mxEvent.getType() as EventType)) return false;
|
||||
|
||||
// Default case
|
||||
return true;
|
||||
const myUserId = MatrixClientPeg.safeGet().getSafeUserId();
|
||||
return isEligibleForSpecialReceipt(this.props.mxEvent, myUserId);
|
||||
}
|
||||
|
||||
private get shouldShowSentReceipt(): boolean {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue