diff --git a/src/components/views/elements/Pill.tsx b/src/components/views/elements/Pill.tsx index 3a14f7b634..1ccc3f36b5 100644 --- a/src/components/views/elements/Pill.tsx +++ b/src/components/views/elements/Pill.tsx @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import React, { useState } from "react"; +import React, { ReactElement, useState } from "react"; import classNames from "classnames"; import { Room } from "matrix-js-sdk/src/models/room"; @@ -22,6 +22,8 @@ import { MatrixClientPeg } from "../../../MatrixClientPeg"; import MatrixClientContext from "../../../contexts/MatrixClientContext"; import Tooltip, { Alignment } from "../elements/Tooltip"; import { usePermalink } from "../../../hooks/usePermalink"; +import RoomAvatar from "../avatars/RoomAvatar"; +import MemberAvatar from "../avatars/MemberAvatar"; export enum PillType { UserMention = "TYPE_USER_MENTION", @@ -52,13 +54,13 @@ export interface PillProps { export const Pill: React.FC = ({ type: propType, url, inMessage, room, shouldShowPillAvatar }) => { const [hover, setHover] = useState(false); - const { avatar, onClick, resourceId, text, type } = usePermalink({ + const { member, onClick, resourceId, targetRoom, text, type } = usePermalink({ room, type: propType, url, }); - if (!type) { + if (!type || !text) { return null; } @@ -79,6 +81,27 @@ export const Pill: React.FC = ({ type: propType, url, inMessage, room }; const tip = hover && resourceId ? : null; + let avatar: ReactElement | null = null; + + switch (type) { + case PillType.AtRoomMention: + case PillType.RoomMention: + case "space": + avatar = targetRoom ?