Apply the auto-fixable lint rules and the formatter, and drop the Vite build artifacts.
This commit is contained in:
@@ -1,7 +1,22 @@
|
||||
import React, { MouseEventHandler, forwardRef, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { Avatar, Box, IconButton, Line, Menu, MenuItem, PopOut, RectCords, Text, Tooltip, TooltipProvider, config, toRem } from 'folds';
|
||||
import { Icon, Icons } from '../../components/icons';
|
||||
import {
|
||||
Avatar,
|
||||
Box,
|
||||
IconButton,
|
||||
Line,
|
||||
Menu,
|
||||
MenuItem,
|
||||
PopOut,
|
||||
RectCords,
|
||||
Text,
|
||||
Tooltip,
|
||||
TooltipProvider,
|
||||
config,
|
||||
toRem,
|
||||
} from 'folds';
|
||||
import FocusTrap from 'focus-trap-react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { Icon, Icons } from '../../components/icons';
|
||||
import { PageHeader } from '../../components/page';
|
||||
import { useSetSetting } from '../../state/hooks/settings';
|
||||
import { settingsAtom } from '../../state/settings';
|
||||
@@ -18,7 +33,7 @@ import { RemoveInaccessiblePrompt } from '../../components/remove-inaccessible-p
|
||||
import { stopPropagation } from '../../utils/keyboard';
|
||||
import { ScreenSize, useScreenSizeContext } from '../../hooks/useScreenSize';
|
||||
import { useBackRoute } from '../../hooks/useBackRoute';
|
||||
import { mxcUrlToHttp } from '../../utils/matrix';
|
||||
import { mxcUrlToHttp, getCanonicalAliasOrRoomId } from '../../utils/matrix';
|
||||
import { useMediaAuthentication } from '../../hooks/useMediaAuthentication';
|
||||
import { useOpenSpaceSettings } from '../../state/hooks/spaceSettings';
|
||||
import { useRoomCreators } from '../../hooks/useRoomCreators';
|
||||
@@ -28,8 +43,6 @@ import { AddExistingModal } from '../add-existing';
|
||||
import { SpeechBubble } from '../../components/speech-bubble/SpeechBubble';
|
||||
import { SpaceOptionsMenu, type OpenAddExistingOptions } from '../space/SpaceOptionsMenu';
|
||||
import type { HierarchyItemSpace } from '../../hooks/useSpaceHierarchy';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { getCanonicalAliasOrRoomId } from '../../utils/matrix';
|
||||
import { getSpaceFeedPath } from '../../pages/pathUtils';
|
||||
import { shouldShowForumLobby } from '../../utils/room';
|
||||
import { useForumBoardContextOptionally } from '../forum/ForumBoardContext';
|
||||
@@ -176,7 +189,7 @@ const LobbyMenu = forwardRef<HTMLDivElement, LobbyMenuProps>(
|
||||
</Box>
|
||||
</Menu>
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
type LobbyHeaderProps = {
|
||||
@@ -200,7 +213,7 @@ export function LobbyHeader({ showProfile, showSpaceToolbar, powerLevels }: Lobb
|
||||
const name = useRoomName(space);
|
||||
const avatarMxc = useRoomAvatar(space);
|
||||
const avatarUrl = avatarMxc
|
||||
? mxcUrlToHttp(mx, avatarMxc, useAuthentication, 96, 96, 'crop') ?? undefined
|
||||
? (mxcUrlToHttp(mx, avatarMxc, useAuthentication, 96, 96, 'crop') ?? undefined)
|
||||
: undefined;
|
||||
|
||||
const forumBoard = useForumBoardContextOptionally();
|
||||
@@ -228,11 +241,11 @@ export function LobbyHeader({ showProfile, showSpaceToolbar, powerLevels }: Lobb
|
||||
space: true,
|
||||
parentId: addParent.roomId === space.roomId ? undefined : space.roomId,
|
||||
}),
|
||||
[addParent.roomId, space.roomId]
|
||||
[addParent.roomId, space.roomId],
|
||||
);
|
||||
|
||||
const canEditChildren = Boolean(
|
||||
spacePermissions.stateEvent(StateEvent.SpaceChild, mx.getSafeUserId())
|
||||
spacePermissions.stateEvent(StateEvent.SpaceChild, mx.getSafeUserId()),
|
||||
);
|
||||
|
||||
const handleOpenMenu: MouseEventHandler<HTMLButtonElement> = (evt) => {
|
||||
@@ -259,7 +272,7 @@ export function LobbyHeader({ showProfile, showSpaceToolbar, powerLevels }: Lobb
|
||||
const isInside = (node: Node | null) => {
|
||||
if (!node) return false;
|
||||
return Boolean(
|
||||
menuWrapperRef.current?.contains(node) || menuTriggerElRef.current?.contains(node)
|
||||
menuWrapperRef.current?.contains(node) || menuTriggerElRef.current?.contains(node),
|
||||
);
|
||||
};
|
||||
|
||||
@@ -299,99 +312,99 @@ export function LobbyHeader({ showProfile, showSpaceToolbar, powerLevels }: Lobb
|
||||
if (showSpaceToolbar) {
|
||||
return (
|
||||
<>
|
||||
<PageHeader outlined>
|
||||
<Box grow="Yes" alignItems="Center" gap="300">
|
||||
{showInPageHeader && (
|
||||
<Box shrink="No">
|
||||
<IconButton onClick={goBack} aria-label="Back">
|
||||
<Icon src={Icons.ArrowLeft} />
|
||||
</IconButton>
|
||||
</Box>
|
||||
)}
|
||||
<Avatar size="300" shrink="No">
|
||||
<RoomAvatar
|
||||
roomId={space.roomId}
|
||||
src={avatarUrl}
|
||||
alt={name}
|
||||
renderFallback={() => <Text size="H4">{nameInitials(name)}</Text>}
|
||||
/>
|
||||
</Avatar>
|
||||
<Text size="H3" truncate style={{ minWidth: 0 }}>
|
||||
{name}
|
||||
</Text>
|
||||
<Box grow="Yes" />
|
||||
<TooltipProvider
|
||||
position="Bottom"
|
||||
align="End"
|
||||
offset={4}
|
||||
tooltip={
|
||||
<Tooltip>
|
||||
<Text>More Options</Text>
|
||||
</Tooltip>
|
||||
}
|
||||
>
|
||||
{(triggerRef) => (
|
||||
<IconButton
|
||||
onClick={handleOpenMenu}
|
||||
ref={triggerRef}
|
||||
aria-pressed={!!menuAnchor}
|
||||
variant="SurfaceVariant"
|
||||
fill="None"
|
||||
size="300"
|
||||
radii="300"
|
||||
>
|
||||
<Icon size="400" src={Icons.VerticalDots} />
|
||||
</IconButton>
|
||||
<PageHeader outlined>
|
||||
<Box grow="Yes" alignItems="Center" gap="300">
|
||||
{showInPageHeader && (
|
||||
<Box shrink="No">
|
||||
<IconButton onClick={goBack} aria-label="Back">
|
||||
<Icon src={Icons.ArrowLeft} />
|
||||
</IconButton>
|
||||
</Box>
|
||||
)}
|
||||
</TooltipProvider>
|
||||
<PopOut
|
||||
anchor={menuAnchor}
|
||||
position="Bottom"
|
||||
align="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,
|
||||
}}
|
||||
>
|
||||
<div ref={menuWrapperRef}>
|
||||
<SpeechBubble variant="menu" tail="top" tailX="calc(100% - 22px)">
|
||||
<SpaceOptionsMenu
|
||||
room={space}
|
||||
requestClose={() => setMenuAnchor(undefined)}
|
||||
onOpenAddExisting={(options) => {
|
||||
setAddExisting(options);
|
||||
setMenuAnchor(undefined);
|
||||
}}
|
||||
forumAdd={
|
||||
forumBoard && canEditChildren
|
||||
? {
|
||||
item: addParentItem,
|
||||
showAddSpace: addParent.showAddSpace,
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
/>
|
||||
</SpeechBubble>
|
||||
</div>
|
||||
</FocusTrap>
|
||||
}
|
||||
<Avatar size="300" shrink="No">
|
||||
<RoomAvatar
|
||||
roomId={space.roomId}
|
||||
src={avatarUrl}
|
||||
alt={name}
|
||||
renderFallback={() => <Text size="H4">{nameInitials(name)}</Text>}
|
||||
/>
|
||||
</Avatar>
|
||||
<Text size="H3" truncate style={{ minWidth: 0 }}>
|
||||
{name}
|
||||
</Text>
|
||||
<Box grow="Yes" />
|
||||
<TooltipProvider
|
||||
position="Bottom"
|
||||
align="End"
|
||||
offset={4}
|
||||
tooltip={
|
||||
<Tooltip>
|
||||
<Text>More Options</Text>
|
||||
</Tooltip>
|
||||
}
|
||||
>
|
||||
{(triggerRef) => (
|
||||
<IconButton
|
||||
onClick={handleOpenMenu}
|
||||
ref={triggerRef}
|
||||
aria-pressed={!!menuAnchor}
|
||||
variant="SurfaceVariant"
|
||||
fill="None"
|
||||
size="300"
|
||||
radii="300"
|
||||
>
|
||||
<Icon size="400" src={Icons.VerticalDots} />
|
||||
</IconButton>
|
||||
)}
|
||||
</TooltipProvider>
|
||||
<PopOut
|
||||
anchor={menuAnchor}
|
||||
position="Bottom"
|
||||
align="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,
|
||||
}}
|
||||
>
|
||||
<div ref={menuWrapperRef}>
|
||||
<SpeechBubble variant="menu" tail="top" tailX="calc(100% - 22px)">
|
||||
<SpaceOptionsMenu
|
||||
room={space}
|
||||
requestClose={() => setMenuAnchor(undefined)}
|
||||
onOpenAddExisting={(options) => {
|
||||
setAddExisting(options);
|
||||
setMenuAnchor(undefined);
|
||||
}}
|
||||
forumAdd={
|
||||
forumBoard && canEditChildren
|
||||
? {
|
||||
item: addParentItem,
|
||||
showAddSpace: addParent.showAddSpace,
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
/>
|
||||
</SpeechBubble>
|
||||
</div>
|
||||
</FocusTrap>
|
||||
}
|
||||
/>
|
||||
</Box>
|
||||
</PageHeader>
|
||||
{addExisting && (
|
||||
<AddExistingModal
|
||||
parentId={addExisting.parentId}
|
||||
space={addExisting.space}
|
||||
requestClose={() => setAddExisting(null)}
|
||||
/>
|
||||
</Box>
|
||||
</PageHeader>
|
||||
{addExisting && (
|
||||
<AddExistingModal
|
||||
parentId={addExisting.parentId}
|
||||
space={addExisting.space}
|
||||
requestClose={() => setAddExisting(null)}
|
||||
/>
|
||||
)}
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user