/* Copyright 2017 - 2019, 2021 The Matrix.org Foundation C.I.C. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ import React, { ReactElement, useState } from "react"; import classNames from "classnames"; import { Room } from "matrix-js-sdk/src/models/room"; import { RoomMember } from "matrix-js-sdk/src/matrix"; 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"; import { _t } from "../../../languageHandler"; import { Icon as LinkIcon } from "../../../../res/img/element-icons/room/composer/link.svg"; import { Icon as UserIcon } from "../../../../res/img/compound/user.svg"; export enum PillType { UserMention = "TYPE_USER_MENTION", RoomMention = "TYPE_ROOM_MENTION", AtRoomMention = "TYPE_AT_ROOM_MENTION", // '@room' mention EventInSameRoom = "TYPE_EVENT_IN_SAME_ROOM", EventInOtherRoom = "TYPE_EVENT_IN_OTHER_ROOM", } export const pillRoomNotifPos = (text: string): number => { return text.indexOf("@room"); }; export const pillRoomNotifLen = (): number => { return "@room".length; }; const linkIcon = ; const PillRoomAvatar: React.FC<{ shouldShowPillAvatar: boolean; room: Room | null; }> = ({ shouldShowPillAvatar, room }) => { if (!shouldShowPillAvatar) { return null; } if (room) { return