2016-08-09 21:40:05 +05:30
|
|
|
/*
|
2024-09-09 14:57:16 +01:00
|
|
|
Copyright 2024 New Vector Ltd.
|
|
|
|
|
Copyright 2023 The Matrix.org Foundation C.I.C.
|
|
|
|
|
Copyright 2015, 2016 OpenMarket Ltd
|
2016-08-09 21:40:05 +05:30
|
|
|
|
2024-09-09 14:57:16 +01:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
|
|
|
|
|
Please see LICENSE files in the repository root for full details.
|
2016-08-09 21:40:05 +05:30
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import React from "react";
|
2023-08-08 11:12:12 +01:00
|
|
|
import { MatrixEvent, MsgType } from "matrix-js-sdk/src/matrix";
|
2021-07-15 11:49:55 +01:00
|
|
|
|
2022-03-22 23:14:55 +01:00
|
|
|
import DisambiguatedProfile from "./DisambiguatedProfile";
|
2022-11-08 10:58:26 +00:00
|
|
|
import { useRoomMemberProfile } from "../../../hooks/room/useRoomMemberProfile";
|
2021-04-20 11:09:03 +02:00
|
|
|
|
|
|
|
|
interface IProps {
|
|
|
|
|
mxEvent: MatrixEvent;
|
2021-07-03 10:59:57 +02:00
|
|
|
onClick?(): void;
|
2023-01-18 15:56:43 +01:00
|
|
|
withTooltip?: boolean;
|
2021-04-20 11:09:03 +02:00
|
|
|
}
|
2016-08-09 21:40:05 +05:30
|
|
|
|
2023-01-18 15:56:43 +01:00
|
|
|
export default function SenderProfile({ mxEvent, onClick, withTooltip }: IProps): JSX.Element {
|
2022-11-08 10:58:26 +00:00
|
|
|
const member = useRoomMemberProfile({
|
|
|
|
|
userId: mxEvent.getSender(),
|
|
|
|
|
member: mxEvent.sender,
|
|
|
|
|
});
|
2017-11-28 15:46:23 +00:00
|
|
|
|
2022-11-08 10:58:26 +00:00
|
|
|
return mxEvent.getContent().msgtype !== MsgType.Emote ? (
|
|
|
|
|
<DisambiguatedProfile
|
|
|
|
|
fallbackName={mxEvent.getSender() ?? ""}
|
|
|
|
|
onClick={onClick}
|
|
|
|
|
member={member}
|
|
|
|
|
colored={true}
|
|
|
|
|
emphasizeDisplayName={true}
|
2023-01-18 15:56:43 +01:00
|
|
|
withTooltip={withTooltip}
|
2022-11-08 10:58:26 +00:00
|
|
|
/>
|
2023-03-13 15:07:20 +00:00
|
|
|
) : (
|
|
|
|
|
<></>
|
|
|
|
|
);
|
2020-08-29 12:14:16 +01:00
|
|
|
}
|