Apply the auto-fixable lint rules and the formatter, and drop the Vite build artifacts.
This commit is contained in:
@@ -37,23 +37,22 @@ export function CallParticipantsIndicator({ roomId }: CallParticipantsIndicatorP
|
||||
return mxcUrlToHttp(mx, mxcUrl, useAuthentication, 48, 48, 'crop') ?? undefined;
|
||||
};
|
||||
|
||||
const getParticipantName = (userId: string): string => {
|
||||
return getMemberDisplayName(room, userId) ?? getMxIdLocalPart(userId) ?? userId;
|
||||
};
|
||||
const getParticipantName = (userId: string): string =>
|
||||
getMemberDisplayName(room, userId) ?? getMxIdLocalPart(userId) ?? userId;
|
||||
|
||||
/**
|
||||
* Check if a participant is currently speaking
|
||||
*/
|
||||
const isParticipantSpeaking = (userId: string): boolean => {
|
||||
if (!activeCall) return false;
|
||||
|
||||
|
||||
// Direct check for Matrix user ID (works for local user)
|
||||
if (activeCall.activeSpeakers.has(userId)) return true;
|
||||
|
||||
|
||||
// For remote users, activeSpeakers contains LiveKit identities (deviceId_timestamp)
|
||||
const member = callMembers.find((m) => m.userId === userId);
|
||||
if (!member) return false;
|
||||
|
||||
|
||||
// Check if any active speaker has this user's deviceId
|
||||
return Array.from(activeCall.activeSpeakers).some((speakerId) => {
|
||||
const underscoreIndex = speakerId.lastIndexOf('_');
|
||||
@@ -67,14 +66,14 @@ export function CallParticipantsIndicator({ roomId }: CallParticipantsIndicatorP
|
||||
*/
|
||||
const isParticipantMuted = (userId: string): boolean => {
|
||||
if (!activeCall) return false;
|
||||
|
||||
|
||||
// For local user, check activeCall.isMuted
|
||||
if (userId === myUserId) return activeCall.isMuted;
|
||||
|
||||
|
||||
// For remote users, mutedParticipants contains LiveKit identities (deviceId_timestamp)
|
||||
const member = callMembers.find((m) => m.userId === userId);
|
||||
if (!member) return false;
|
||||
|
||||
|
||||
// Check if any muted participant has this user's deviceId
|
||||
return Array.from(activeCall.mutedParticipants).some((mutedId) => {
|
||||
const underscoreIndex = mutedId.lastIndexOf('_');
|
||||
@@ -115,7 +114,7 @@ export function CallParticipantsIndicator({ roomId }: CallParticipantsIndicatorP
|
||||
const isSpeaking = isParticipantSpeaking(member.userId);
|
||||
const isMuted = isParticipantMuted(member.userId);
|
||||
const isDeafened = isLocalUserDeafened(member.userId);
|
||||
|
||||
|
||||
return (
|
||||
<Box
|
||||
key={member.userId}
|
||||
@@ -125,8 +124,8 @@ export function CallParticipantsIndicator({ roomId }: CallParticipantsIndicatorP
|
||||
opacity: config.opacity.P300,
|
||||
}}
|
||||
>
|
||||
<Avatar
|
||||
size="200"
|
||||
<Avatar
|
||||
size="200"
|
||||
radii="Pill"
|
||||
className={isSpeaking ? css.ParticipantSpeaking : undefined}
|
||||
>
|
||||
@@ -148,13 +147,17 @@ export function CallParticipantsIndicator({ roomId }: CallParticipantsIndicatorP
|
||||
)}
|
||||
</Avatar>
|
||||
<Box alignItems="Center" gap="100" grow="Yes">
|
||||
<Icon
|
||||
src={getAudioIcon(member.userId)}
|
||||
size="50"
|
||||
style={{
|
||||
<Icon
|
||||
src={getAudioIcon(member.userId)}
|
||||
size="50"
|
||||
style={{
|
||||
opacity: config.opacity.P500,
|
||||
color: isDeafened ? 'var(--color-Critical-Main)' : isMuted ? 'var(--color-Critical-Main)' : undefined
|
||||
}}
|
||||
color: isDeafened
|
||||
? 'var(--color-Critical-Main)'
|
||||
: isMuted
|
||||
? 'var(--color-Critical-Main)'
|
||||
: undefined,
|
||||
}}
|
||||
/>
|
||||
<Text as="span" size="T200" truncate>
|
||||
{getParticipantName(member.userId)}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import { as, Chip, Text } from 'folds';
|
||||
import { Icon, Icons } from '../../components/icons';
|
||||
import classNames from 'classnames';
|
||||
import { Icon, Icons } from '../../components/icons';
|
||||
import * as css from './styles.css';
|
||||
|
||||
export const RoomNavCategoryButton = as<'button', { closed?: boolean }>(
|
||||
@@ -25,5 +25,5 @@ export const RoomNavCategoryButton = as<'button', { closed?: boolean }>(
|
||||
{children}
|
||||
</Text>
|
||||
</Chip>
|
||||
)
|
||||
),
|
||||
);
|
||||
|
||||
@@ -2,15 +2,36 @@ import React, { MouseEventHandler, forwardRef, useState, useMemo } from 'react';
|
||||
import { Room, EventTimeline } from 'matrix-js-sdk';
|
||||
import { useAtomValue } from 'jotai';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { Avatar, Box, IconButton, Text, Menu, MenuItem, config, PopOut, toRem, Line, RectCords, Badge, Spinner, Tooltip, TooltipProvider } from 'folds';
|
||||
import { Icon, Icons } from '../../components/icons';
|
||||
import {
|
||||
Avatar,
|
||||
Box,
|
||||
IconButton,
|
||||
Text,
|
||||
Menu,
|
||||
MenuItem,
|
||||
config,
|
||||
PopOut,
|
||||
toRem,
|
||||
Line,
|
||||
RectCords,
|
||||
Badge,
|
||||
Spinner,
|
||||
Tooltip,
|
||||
TooltipProvider,
|
||||
} from 'folds';
|
||||
import { useFocusWithin, useHover } from 'react-aria';
|
||||
import FocusTrap from 'focus-trap-react';
|
||||
import { Icon, Icons } from '../../components/icons';
|
||||
import { NavItem, NavItemContent, NavItemOptions, NavLink } from '../../components/nav';
|
||||
import * as css from '../../components/nav/styles.css';
|
||||
import { UnreadBadge, UnreadBadgeCenter } from '../../components/unread-badge';
|
||||
import { RoomAvatar, RoomIcon } from '../../components/room-avatar';
|
||||
import { getDirectRoomAvatarUrl, getRoomAvatarUrl, guessPerfectParent, getOrphanParents } from '../../utils/room';
|
||||
import {
|
||||
getDirectRoomAvatarUrl,
|
||||
getRoomAvatarUrl,
|
||||
guessPerfectParent,
|
||||
getOrphanParents,
|
||||
} from '../../utils/room';
|
||||
import { nameInitials } from '../../utils/common';
|
||||
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
||||
import { useRoomUnread } from '../../state/hooks/unread';
|
||||
@@ -24,7 +45,12 @@ import { useRoomTypingMember } from '../../hooks/useRoomTypingMembers';
|
||||
import { TypingIndicator } from '../../components/typing-indicator';
|
||||
import { stopPropagation } from '../../utils/keyboard';
|
||||
import { getMatrixToRoom } from '../../plugins/matrix-to';
|
||||
import { getCanonicalAliasOrRoomId, guessDmRoomUserId, isRoomAlias, mxcUrlToHttp } from '../../utils/matrix';
|
||||
import {
|
||||
getCanonicalAliasOrRoomId,
|
||||
guessDmRoomUserId,
|
||||
isRoomAlias,
|
||||
mxcUrlToHttp,
|
||||
} from '../../utils/matrix';
|
||||
import { getViaServers } from '../../plugins/via-servers';
|
||||
import { useMediaAuthentication } from '../../hooks/useMediaAuthentication';
|
||||
import { useSetting } from '../../state/hooks/settings';
|
||||
@@ -257,7 +283,7 @@ const RoomNavItemMenu = forwardRef<HTMLDivElement, RoomNavItemMenuProps>(
|
||||
</Box>
|
||||
</Menu>
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
type RoomNavItemProps = {
|
||||
@@ -296,10 +322,10 @@ export function RoomNavItem({
|
||||
const isDirect = Boolean(direct || mDirects.has(room.roomId));
|
||||
const dmUserId = isDirect ? guessDmRoomUserId(room, mx.getSafeUserId()) : undefined;
|
||||
const dmPresence = useUserPresence(dmUserId ?? '');
|
||||
|
||||
|
||||
const shouldShowIcon = !hideIcon || (hideIcon && avatarUrl);
|
||||
const typingMember = useRoomTypingMember(room.roomId).filter(
|
||||
(receipt) => receipt.userId !== mx.getUserId()
|
||||
(receipt) => receipt.userId !== mx.getUserId(),
|
||||
);
|
||||
const roomToParents = useAtomValue(roomToParentsAtom);
|
||||
|
||||
@@ -311,7 +337,7 @@ export function RoomNavItem({
|
||||
if (participatedThreads.length === 0) return undefined;
|
||||
|
||||
const firstThread = participatedThreads[0];
|
||||
const rootEvent = firstThread.rootEvent;
|
||||
const { rootEvent } = firstThread;
|
||||
if (!rootEvent) return undefined;
|
||||
|
||||
const rootBody = rootEvent.getContent()?.body ?? '';
|
||||
@@ -324,18 +350,24 @@ export function RoomNavItem({
|
||||
// Get parent space for DMs
|
||||
const parentSpaceInfo = (() => {
|
||||
if (!isDirect || !mDirects.has(room.roomId)) return undefined;
|
||||
|
||||
|
||||
const orphanParents = getOrphanParents(roomToParents, room.roomId);
|
||||
if (orphanParents.length === 0) return undefined;
|
||||
|
||||
|
||||
const parentSpaceId = guessPerfectParent(mx, room.roomId, orphanParents) ?? orphanParents[0];
|
||||
const parentSpace = mx.getRoom(parentSpaceId);
|
||||
if (!parentSpace) return undefined;
|
||||
|
||||
const avatarEvent = parentSpace.getLiveTimeline().getState(EventTimeline.FORWARDS)?.getStateEvents(StateEvent.RoomAvatar, '');
|
||||
const avatarEvent = parentSpace
|
||||
.getLiveTimeline()
|
||||
.getState(EventTimeline.FORWARDS)
|
||||
?.getStateEvents(StateEvent.RoomAvatar, '');
|
||||
const avatarContent = avatarEvent?.getContent();
|
||||
const avatarMxc = avatarContent && typeof avatarContent.url === 'string' ? avatarContent.url : undefined;
|
||||
const avatarUrl = avatarMxc ? mxcUrlToHttp(mx, avatarMxc, useAuthentication, 96, 96, 'crop') ?? undefined : undefined;
|
||||
const avatarMxc =
|
||||
avatarContent && typeof avatarContent.url === 'string' ? avatarContent.url : undefined;
|
||||
const avatarUrl = avatarMxc
|
||||
? (mxcUrlToHttp(mx, avatarMxc, useAuthentication, 96, 96, 'crop') ?? undefined)
|
||||
: undefined;
|
||||
|
||||
return {
|
||||
name: parentSpace.name,
|
||||
@@ -360,11 +392,11 @@ export function RoomNavItem({
|
||||
const handleRoomClick: MouseEventHandler<HTMLAnchorElement> = (evt) => {
|
||||
if (selected) {
|
||||
evt.preventDefault();
|
||||
|
||||
const shouldScroll =
|
||||
|
||||
const shouldScroll =
|
||||
scrollToLatestBehavior === ScrollToLatestBehavior.Always ||
|
||||
(scrollToLatestBehavior === ScrollToLatestBehavior.OnNewMessage && unread !== undefined);
|
||||
|
||||
|
||||
if (shouldScroll) {
|
||||
navigate(linkPath, { replace: true, state: { scrollToLatest: Date.now() } });
|
||||
}
|
||||
@@ -388,13 +420,13 @@ export function RoomNavItem({
|
||||
>
|
||||
<NavLink to={linkPath} onClick={handleRoomClick}>
|
||||
<NavItemContent>
|
||||
<Box as="span" grow="Yes" alignItems="Center" gap={shouldShowIcon ? "200" : "100"}>
|
||||
<Box as="span" grow="Yes" alignItems="Center" gap={shouldShowIcon ? '200' : '100'}>
|
||||
{shouldShowIcon &&
|
||||
(isDirect ? (
|
||||
<PresenceAvatar
|
||||
presence={
|
||||
dmUserId && dmUserId !== mx.getSafeUserId()
|
||||
? dmPresence?.presence ?? Presence.Offline
|
||||
? (dmPresence?.presence ?? Presence.Offline)
|
||||
: Presence.Offline
|
||||
}
|
||||
>
|
||||
@@ -443,7 +475,12 @@ export function RoomNavItem({
|
||||
)}
|
||||
</Avatar>
|
||||
))}
|
||||
<Box as="span" grow="Yes" direction="Column" style={{ overflow: 'hidden', minWidth: 0 }}>
|
||||
<Box
|
||||
as="span"
|
||||
grow="Yes"
|
||||
direction="Column"
|
||||
style={{ overflow: 'hidden', minWidth: 0 }}
|
||||
>
|
||||
<Text priority={unread ? '500' : '300'} as="span" size="Inherit" truncate>
|
||||
{room.name}
|
||||
</Text>
|
||||
@@ -469,76 +506,79 @@ export function RoomNavItem({
|
||||
</Box>
|
||||
</NavItemContent>
|
||||
</NavLink>
|
||||
{optionsVisible && (
|
||||
<NavItemOptions>
|
||||
<Box alignItems="Center" gap="100">
|
||||
{parentSpaceInfo && (
|
||||
<TooltipProvider
|
||||
position="Top"
|
||||
tooltip={
|
||||
<Tooltip>
|
||||
<Text size="T200">Space: {parentSpaceInfo.name}</Text>
|
||||
</Tooltip>
|
||||
}
|
||||
>
|
||||
{(triggerRef) => (
|
||||
<Avatar ref={triggerRef} size="200" radii="Pill" style={{ flexShrink: 0, width: '16px', height: '16px' }}>
|
||||
<RoomAvatar
|
||||
roomId={parentSpaceInfo.roomId}
|
||||
src={parentSpaceInfo.avatarUrl}
|
||||
alt={parentSpaceInfo.name}
|
||||
renderFallback={() => (
|
||||
<Text size="Inherit">
|
||||
{nameInitials(parentSpaceInfo.name, 1)}
|
||||
</Text>
|
||||
)}
|
||||
/>
|
||||
</Avatar>
|
||||
)}
|
||||
</TooltipProvider>
|
||||
)}
|
||||
{optionsVisible && (
|
||||
<PopOut
|
||||
anchor={menuAnchor}
|
||||
offset={menuAnchor?.width === 0 ? 0 : undefined}
|
||||
alignOffset={menuAnchor?.width === 0 ? 0 : -5}
|
||||
position="Bottom"
|
||||
align={menuAnchor?.width === 0 ? 'Start' : 'End'}
|
||||
content={
|
||||
<FocusTrap
|
||||
focusTrapOptions={{
|
||||
initialFocus: false,
|
||||
returnFocusOnDeactivate: false,
|
||||
onDeactivate: () => setMenuAnchor(undefined),
|
||||
clickOutsideDeactivates: true,
|
||||
isKeyForward: (evt: KeyboardEvent) => evt.key === 'ArrowDown',
|
||||
isKeyBackward: (evt: KeyboardEvent) => evt.key === 'ArrowUp',
|
||||
escapeDeactivates: stopPropagation,
|
||||
}}
|
||||
>
|
||||
<RoomNavItemMenu
|
||||
room={room}
|
||||
requestClose={() => setMenuAnchor(undefined)}
|
||||
notificationMode={notificationMode}
|
||||
/>
|
||||
</FocusTrap>
|
||||
}
|
||||
>
|
||||
<IconButton
|
||||
onClick={handleOpenMenu}
|
||||
aria-pressed={!!menuAnchor}
|
||||
variant="Background"
|
||||
fill="None"
|
||||
size="300"
|
||||
radii="300"
|
||||
{optionsVisible && (
|
||||
<NavItemOptions>
|
||||
<Box alignItems="Center" gap="100">
|
||||
{parentSpaceInfo && (
|
||||
<TooltipProvider
|
||||
position="Top"
|
||||
tooltip={
|
||||
<Tooltip>
|
||||
<Text size="T200">Space: {parentSpaceInfo.name}</Text>
|
||||
</Tooltip>
|
||||
}
|
||||
>
|
||||
<Icon size="50" src={Icons.VerticalDots} />
|
||||
</IconButton>
|
||||
</PopOut>
|
||||
)}
|
||||
</Box>
|
||||
</NavItemOptions>
|
||||
)}
|
||||
{(triggerRef) => (
|
||||
<Avatar
|
||||
ref={triggerRef}
|
||||
size="200"
|
||||
radii="Pill"
|
||||
style={{ flexShrink: 0, width: '16px', height: '16px' }}
|
||||
>
|
||||
<RoomAvatar
|
||||
roomId={parentSpaceInfo.roomId}
|
||||
src={parentSpaceInfo.avatarUrl}
|
||||
alt={parentSpaceInfo.name}
|
||||
renderFallback={() => (
|
||||
<Text size="Inherit">{nameInitials(parentSpaceInfo.name, 1)}</Text>
|
||||
)}
|
||||
/>
|
||||
</Avatar>
|
||||
)}
|
||||
</TooltipProvider>
|
||||
)}
|
||||
{optionsVisible && (
|
||||
<PopOut
|
||||
anchor={menuAnchor}
|
||||
offset={menuAnchor?.width === 0 ? 0 : undefined}
|
||||
alignOffset={menuAnchor?.width === 0 ? 0 : -5}
|
||||
position="Bottom"
|
||||
align={menuAnchor?.width === 0 ? 'Start' : 'End'}
|
||||
content={
|
||||
<FocusTrap
|
||||
focusTrapOptions={{
|
||||
initialFocus: false,
|
||||
returnFocusOnDeactivate: false,
|
||||
onDeactivate: () => setMenuAnchor(undefined),
|
||||
clickOutsideDeactivates: true,
|
||||
isKeyForward: (evt: KeyboardEvent) => evt.key === 'ArrowDown',
|
||||
isKeyBackward: (evt: KeyboardEvent) => evt.key === 'ArrowUp',
|
||||
escapeDeactivates: stopPropagation,
|
||||
}}
|
||||
>
|
||||
<RoomNavItemMenu
|
||||
room={room}
|
||||
requestClose={() => setMenuAnchor(undefined)}
|
||||
notificationMode={notificationMode}
|
||||
/>
|
||||
</FocusTrap>
|
||||
}
|
||||
>
|
||||
<IconButton
|
||||
onClick={handleOpenMenu}
|
||||
aria-pressed={!!menuAnchor}
|
||||
variant="Background"
|
||||
fill="None"
|
||||
size="300"
|
||||
radii="300"
|
||||
>
|
||||
<Icon size="50" src={Icons.VerticalDots} />
|
||||
</IconButton>
|
||||
</PopOut>
|
||||
)}
|
||||
</Box>
|
||||
</NavItemOptions>
|
||||
)}
|
||||
</NavItem>
|
||||
<CallParticipantsIndicator roomId={room.roomId} />
|
||||
</Box>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React, { useCallback } from 'react';
|
||||
import { Box, Chip, Spinner, Text, Tooltip, TooltipProvider, color, config, toRem } from 'folds';
|
||||
import { Icon, Icons } from '../../components/icons';
|
||||
import { MatrixError, Room } from 'matrix-js-sdk';
|
||||
import { Icon, Icons } from '../../components/icons';
|
||||
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
||||
import { AsyncStatus, useAsyncCallback } from '../../hooks/useAsyncCallback';
|
||||
|
||||
@@ -28,12 +28,12 @@ export function UnjoinedSubRoomItem({ roomId, depth, isLast = false }: UnjoinedS
|
||||
const viaServers = [getServerFromRoomId(roomId)].filter(Boolean);
|
||||
|
||||
const [joinState, join] = useAsyncCallback<Room, MatrixError, []>(
|
||||
useCallback(() => mx.joinRoom(roomId, { viaServers }), [mx, roomId, viaServers])
|
||||
useCallback(() => mx.joinRoom(roomId, { viaServers }), [mx, roomId, viaServers]),
|
||||
);
|
||||
|
||||
const canJoin = joinState.status === AsyncStatus.Idle || joinState.status === AsyncStatus.Error;
|
||||
const paddingLeft = depth > 0 ? '30px' : undefined;
|
||||
|
||||
|
||||
let treeIcon = '';
|
||||
if (depth > 0) {
|
||||
treeIcon = isLast ? '╰' : '├';
|
||||
@@ -52,15 +52,17 @@ export function UnjoinedSubRoomItem({ roomId, depth, isLast = false }: UnjoinedS
|
||||
gap="200"
|
||||
>
|
||||
{treeIcon && (
|
||||
<span style={{
|
||||
paddingRight: '2px',
|
||||
opacity: 0.5,
|
||||
fontFamily: 'monospace',
|
||||
fontSize: '14px',
|
||||
lineHeight: '1',
|
||||
userSelect: 'none',
|
||||
marginLeft: '-10px'
|
||||
}}>
|
||||
<span
|
||||
style={{
|
||||
paddingRight: '2px',
|
||||
opacity: 0.5,
|
||||
fontFamily: 'monospace',
|
||||
fontSize: '14px',
|
||||
lineHeight: '1',
|
||||
userSelect: 'none',
|
||||
marginLeft: '-10px',
|
||||
}}
|
||||
>
|
||||
{treeIcon}
|
||||
</span>
|
||||
)}
|
||||
@@ -96,7 +98,11 @@ export function UnjoinedSubRoomItem({ roomId, depth, isLast = false }: UnjoinedS
|
||||
size="400"
|
||||
radii="Pill"
|
||||
before={
|
||||
canJoin ? <Icon src={Icons.Plus} size="50" /> : <Spinner variant="Secondary" size="50" />
|
||||
canJoin ? (
|
||||
<Icon src={Icons.Plus} size="50" />
|
||||
) : (
|
||||
<Spinner variant="Secondary" size="50" />
|
||||
)
|
||||
}
|
||||
onClick={join}
|
||||
disabled={!canJoin}
|
||||
|
||||
Reference in New Issue
Block a user