Make read receipts handle nullable roomMembers correctly (#8410)

* make readReceipt roomMember nullable, as it should be
* add fallback click interaction for read receipts of unknown users
This commit is contained in:
Janne Mareike Koschinski 2022-04-26 12:35:05 +02:00 committed by GitHub
parent a70f11704f
commit e7c91397f1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 6 deletions

View file

@ -15,6 +15,7 @@ limitations under the License.
*/
import React, { PropsWithChildren, useRef } from "react";
import { User } from "matrix-js-sdk/src/matrix";
import ReadReceiptMarker, { IReadReceiptInfo } from "./ReadReceiptMarker";
import { IReadReceiptProps } from "./EventTile";
@ -188,7 +189,7 @@ function ReadReceiptPerson({ userId, roomMember, ts, isTwelveHour, onAfterClick
label: (
<>
<div className="mx_Tooltip_title">
{ roomMember.rawDisplayName ?? userId }
{ roomMember?.rawDisplayName ?? userId }
</div>
<div className="mx_Tooltip_sub">
{ userId }
@ -203,7 +204,11 @@ function ReadReceiptPerson({ userId, roomMember, ts, isTwelveHour, onAfterClick
onClick={() => {
dis.dispatch({
action: Action.ViewUser,
member: roomMember,
// XXX: We should be using a real member object and not assuming what the receiver wants.
// The ViewUser action leads to the RightPanelStore, and RightPanelStoreIPanelState defines the
// member property of IRightPanelCardState as `RoomMember | User`, so were fine for now, but we
// should definitely clean this up later
member: roomMember ?? { userId } as User,
push: false,
});
onAfterClick?.();
@ -225,7 +230,7 @@ function ReadReceiptPerson({ userId, roomMember, ts, isTwelveHour, onAfterClick
hideTitle
/>
<div className="mx_ReadReceiptGroup_name">
<p>{ roomMember.name }</p>
<p>{ roomMember?.name ?? userId }</p>
<p className="mx_ReadReceiptGroup_secondary">
{ formatDate(new Date(ts), isTwelveHour) }
</p>