* add option to start video all in DM * show speaker icon for dm's in call status name * show call view if call is active in room * add Atria call ringtone * update element call and widget api * add option to start voice/video call in dms * only show call button if user have permission * allow call widget to send call notification event * show incoming call dialog and play sound * fix call permission checks * allow option to start call in all rooms * send notification when starting call in non-voice rooms * hide header call button from voice rooms * prevent call join if call not supported and started by other party * update call menu style * show call not supported message on incoming call notification * improve the incoming call layout * video call with right click without opening menu * allow call widget to fetch media url * add webRTC missing error * improve call permission label --------- Co-authored-by: Krishan <33421343+kfiven@users.noreply.github.com>
59 lines
2.1 KiB
TypeScript
59 lines
2.1 KiB
TypeScript
import React from 'react';
|
|
import { Room } from 'matrix-js-sdk';
|
|
import { Chip, Icon, Icons, Text } from 'folds';
|
|
import { useAtomValue } from 'jotai';
|
|
import { useRoomName } from '../../hooks/useRoomMeta';
|
|
import { RoomIcon } from '../../components/room-avatar';
|
|
import { roomToParentsAtom } from '../../state/room/roomToParents';
|
|
import { getAllParents, guessPerfectParent } from '../../utils/room';
|
|
import { useOrphanSpaces } from '../../state/hooks/roomList';
|
|
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
|
import { allRoomsAtom } from '../../state/room-list/roomList';
|
|
import { mDirectAtom } from '../../state/mDirectList';
|
|
import { useAllJoinedRoomsSet, useGetRoom } from '../../hooks/useGetRoom';
|
|
import { useRoomNavigate } from '../../hooks/useRoomNavigate';
|
|
|
|
type CallRoomNameProps = {
|
|
room: Room;
|
|
};
|
|
export function CallRoomName({ room }: CallRoomNameProps) {
|
|
const mx = useMatrixClient();
|
|
const name = useRoomName(room);
|
|
const roomToParents = useAtomValue(roomToParentsAtom);
|
|
const orphanSpaces = useOrphanSpaces(mx, allRoomsAtom, roomToParents);
|
|
const mDirects = useAtomValue(mDirectAtom);
|
|
const dm = mDirects.has(room.roomId);
|
|
|
|
const allRoomsSet = useAllJoinedRoomsSet();
|
|
const getRoom = useGetRoom(allRoomsSet);
|
|
|
|
const allParents = getAllParents(roomToParents, room.roomId);
|
|
const orphanParents = allParents && orphanSpaces.filter((o) => allParents.has(o));
|
|
const perfectOrphanParent = orphanParents && guessPerfectParent(mx, room.roomId, orphanParents);
|
|
|
|
const { navigateRoom } = useRoomNavigate();
|
|
|
|
return (
|
|
<Chip
|
|
variant="Background"
|
|
radii="Pill"
|
|
before={
|
|
dm ? (
|
|
<Icon size="200" src={Icons.VolumeHigh} filled />
|
|
) : (
|
|
<RoomIcon size="200" joinRule={room.getJoinRule()} roomType={room.getType()} filled />
|
|
)
|
|
}
|
|
onClick={() => navigateRoom(room.roomId)}
|
|
>
|
|
<Text size="L400" truncate>
|
|
{name}
|
|
{!dm && perfectOrphanParent && (
|
|
<Text as="span" size="T200" priority="300">
|
|
{' •'} <b>{getRoom(perfectOrphanParent)?.name ?? perfectOrphanParent}</b>
|
|
</Text>
|
|
)}
|
|
</Text>
|
|
</Chip>
|
|
);
|
|
}
|