mirror of
https://github.com/SableClient/Sable.git
synced 2026-11-24 02:51:17 -08:00
Change cross-cutting hooks to shared modules and fix menu, thread and sheet regressions (#1367)
### Description Adds a generalized `useMatrixEvent` hook, `useAsyncAction`/`AsyncButton`, a shared `RoomMenu`/`useRoomMenuActions`, and splits `utils/room.ts` into `unread`, `relations`, `hierarchy` and `display` modules with no barrel. Folds `ThreadDrawer` onto `useTimelineActions` and the shared renderer context, and moves the call feature into `features/call/`. Also fixes regressions found while reviewing the stack: right-click menus not opening or not anchoring at the cursor, long-press opening the desktop popout instead of the mobile sheet, swipe-to-dismiss shrinking to the drag handle, bottom sheets losing their sheet styling and `role="dialog"`, thread reactions double-reacting instead of redacting, the thread root being unrepliable, and the DM invite prompt never rendering. #### Type of change - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update ### Checklist: - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [x] I have made corresponding changes to the documentation - [x] My changes generate no new warnings ### AI disclosure: - [ ] Partially AI assisted (clarify which code was AI assisted and briefly explain what it does). - [ ] Fully AI generated (explain what all the generated code does in moderate detail). <!-- TODO: fill this in yourself — the template forbids generating it. -->
This commit is contained in:
252 files changed
+6779
-5547
No files matched your search
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
Fix context menus, message long-press, bottom sheet swipe-to-dismiss, thread reactions, thread root replies, and the direct conversation invite prompt.
|
||||
@@ -27,12 +27,15 @@ export default defineConfig({
|
||||
reducedMotion: 'reduce',
|
||||
},
|
||||
projects: [
|
||||
// touch.spec.ts drives page.touchscreen, which throws unless hasTouch is set.
|
||||
{
|
||||
name: 'desktop',
|
||||
testIgnore: /touch\.spec\.ts/,
|
||||
use: { ...devices['Desktop Chrome'], viewport: { width: 1280, height: 800 } },
|
||||
},
|
||||
{
|
||||
name: 'mobile',
|
||||
testIgnore: /touch\.spec\.ts/,
|
||||
use: { ...devices['Desktop Chrome'], viewport: { width: 390, height: 844 } },
|
||||
},
|
||||
// hasTouch + isMobile: covers long-press, swipe-to-dismiss and tap targets,
|
||||
|
||||
@@ -5,10 +5,8 @@ import {
|
||||
Text,
|
||||
IconButton,
|
||||
Input,
|
||||
Button,
|
||||
TextArea as TextAreaComponent,
|
||||
color,
|
||||
Spinner,
|
||||
Chip,
|
||||
Scroll,
|
||||
config,
|
||||
@@ -18,11 +16,13 @@ import type { MatrixError } from '$types/matrix-sdk';
|
||||
import { Cursor } from '$plugins/text-area';
|
||||
import { syntaxErrorPosition } from '$utils/dom';
|
||||
import { AsyncStatus, useAsyncCallback } from '$hooks/useAsyncCallback';
|
||||
import { AsyncError } from '$components/AsyncError';
|
||||
import { useAlive } from '$hooks/useAlive';
|
||||
import { useTextAreaCodeEditor } from '$hooks/useTextAreaCodeEditor';
|
||||
import { Page, PageHeader } from './page';
|
||||
import { SequenceCard } from './sequence-card';
|
||||
import { TextViewerContent } from './text-viewer';
|
||||
import { Button } from '$components/button';
|
||||
|
||||
const EDITOR_INTENT_SPACE_COUNT = 2;
|
||||
|
||||
@@ -139,8 +139,10 @@ function AccountDataEdit({
|
||||
size="400"
|
||||
radii="300"
|
||||
type="submit"
|
||||
disabled={submitting}
|
||||
before={submitting && <Spinner variant="Primary" fill="Solid" size="300" />}
|
||||
loading={submitting}
|
||||
spinnerSize="300"
|
||||
spinnerVariant="Primary"
|
||||
spinnerFill="Solid"
|
||||
>
|
||||
<Text size="B400">Save</Text>
|
||||
</Button>
|
||||
@@ -157,11 +159,7 @@ function AccountDataEdit({
|
||||
</Button>
|
||||
</Box>
|
||||
|
||||
{submitState.status === AsyncStatus.Error && (
|
||||
<Text size="T200" style={{ color: color.Critical.Main }}>
|
||||
<b>{submitState.error.message}</b>
|
||||
</Text>
|
||||
)}
|
||||
<AsyncError state={submitState} bold />
|
||||
</Box>
|
||||
<Box grow="Yes" direction="Column" gap="100">
|
||||
<Box shrink="No">
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import { Text, color } from 'folds';
|
||||
import type { AsyncState } from '$hooks/useAsyncCallback';
|
||||
import { AsyncStatus } from '$hooks/useAsyncCallback';
|
||||
|
||||
type AsyncErrorProps = {
|
||||
state: AsyncState<unknown, unknown>;
|
||||
prefix?: string;
|
||||
size?: 'T200' | 'T300';
|
||||
bold?: boolean;
|
||||
};
|
||||
|
||||
export function AsyncError({ state, prefix, size = 'T200', bold }: AsyncErrorProps) {
|
||||
if (state.status !== AsyncStatus.Error) return null;
|
||||
|
||||
const message = prefix
|
||||
? `${prefix}! ${state.error instanceof Error ? state.error.message : String(state.error)}`
|
||||
: state.error instanceof Error
|
||||
? state.error.message
|
||||
: String(state.error);
|
||||
|
||||
const content = bold ? <b>{message}</b> : message;
|
||||
|
||||
return (
|
||||
<Text style={{ color: color.Critical.Main }} size={size}>
|
||||
{content}
|
||||
</Text>
|
||||
);
|
||||
}
|
||||
@@ -15,7 +15,7 @@ import { useClientWidgetApiEvent, ElementWidgetActions } from '$plugins/call';
|
||||
import { callChatAtom, callEmbedAtom, callEmbedStartErrorAtom } from '$state/callEmbed';
|
||||
import { useSelectedRoom } from '$hooks/router/useSelectedRoom';
|
||||
import { ScreenSize, useScreenSizeContext } from '$hooks/useScreenSize';
|
||||
import { IncomingCallModal } from './IncomingCallModal';
|
||||
import { IncomingCallModal } from '$features/call/IncomingCallModal';
|
||||
import { toCallEmbedStartError } from '$plugins/call/callEmbedError';
|
||||
|
||||
function CallUtils({ embed }: { embed: CallEmbed }) {
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { ShowSasCallbacks, VerificationRequest, Verifier } from '$types/mat
|
||||
import { VerificationPhase, VerificationMethod } from '$types/matrix-sdk';
|
||||
import type { CSSProperties } from 'react';
|
||||
import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import { Box, Button, config, Dialog, Header, IconButton, Spinner, Text } from 'folds';
|
||||
import { Box, config, Dialog, Header, IconButton, Spinner, Text } from 'folds';
|
||||
import { composerIcon, X } from '$components/icons/phosphor';
|
||||
import * as Sentry from '@sentry/react';
|
||||
import {
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
import { AsyncStatus, useAsyncCallback } from '$hooks/useAsyncCallback';
|
||||
import { ContainerColor } from '$styles/ContainerColor.css';
|
||||
import { ModalOverlay } from '$components/modal-overlay/ModalOverlay';
|
||||
import { Button } from '$components/button';
|
||||
|
||||
const DialogHeaderStyles: CSSProperties = {
|
||||
padding: `0 ${config.space.S200} 0 ${config.space.S400}`,
|
||||
@@ -67,8 +68,9 @@ function VerificationAccept({ onAccept }: VerificationAcceptProps) {
|
||||
variant="Primary"
|
||||
fill="Solid"
|
||||
onClick={accept}
|
||||
before={accepting && <Spinner size="100" variant="Primary" fill="Solid" />}
|
||||
disabled={accepting}
|
||||
loading={accepting}
|
||||
spinnerSize="100"
|
||||
spinnerVariant="Primary"
|
||||
>
|
||||
<Text size="B400">Accept</Text>
|
||||
</Button>
|
||||
@@ -140,8 +142,9 @@ function CompareEmoji({ sasData }: { sasData: ShowSasCallbacks }) {
|
||||
variant="Primary"
|
||||
fill="Soft"
|
||||
onClick={confirm}
|
||||
disabled={confirming}
|
||||
before={confirming && <Spinner size="100" variant="Primary" />}
|
||||
loading={confirming}
|
||||
spinnerSize="100"
|
||||
spinnerVariant="Primary"
|
||||
>
|
||||
<Text size="B400">They Match</Text>
|
||||
</Button>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { FormEventHandler } from 'react';
|
||||
import { forwardRef, useCallback, useState } from 'react';
|
||||
import { Dialog, Header, Box, Text, IconButton, config, Button, Chip, color, Spinner } from 'folds';
|
||||
import { Dialog, Header, Box, Text, IconButton, config, Chip } from 'folds';
|
||||
import { AsyncError } from '$components/AsyncError';
|
||||
import { composerIcon, X } from '$components/icons/phosphor';
|
||||
import { saveFileToDevice } from '$utils/download';
|
||||
import to from 'await-to-js';
|
||||
@@ -15,6 +16,7 @@ import { useAlive } from '$hooks/useAlive';
|
||||
import { PasswordInput } from './password-input';
|
||||
import { ActionUIA, ActionUIAFlowsLoader } from './ActionUIA';
|
||||
import { UseStateProvider } from './UseStateProvider';
|
||||
import { Button } from '$components/button';
|
||||
|
||||
type UIACallback<T> = (
|
||||
authDict: AuthDict | null
|
||||
@@ -227,18 +229,10 @@ function SetupVerification({ onComplete, reset }: Readonly<SetupVerificationProp
|
||||
<Text size="L400">Passphrase (Optional)</Text>
|
||||
<PasswordInput name="passphraseInput" size="400" readOnly={loading} />
|
||||
</Box>
|
||||
<Button
|
||||
type="submit"
|
||||
disabled={loading}
|
||||
before={loading && <Spinner size="200" variant="Primary" fill="Solid" />}
|
||||
>
|
||||
<Button type="submit" loading={loading} spinnerSize="200" spinnerVariant="Primary">
|
||||
<Text size="B400">Continue</Text>
|
||||
</Button>
|
||||
{setupState.status === AsyncStatus.Error && (
|
||||
<Text size="T200" style={{ color: color.Critical.Main }}>
|
||||
<b>{setupState.error ? setupState.error.message : 'Unexpected Error!'}</b>
|
||||
</Text>
|
||||
)}
|
||||
<AsyncError state={setupState} bold />
|
||||
{nextAuthData !== null && uiaAction && (
|
||||
<ActionUIAFlowsLoader
|
||||
authData={nextAuthData ?? uiaAction.authData}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { forwardRef, useCallback } from 'react';
|
||||
import { Dialog, Header, config, Box, Text, Button, Spinner, color } from 'folds';
|
||||
import { Dialog, Header, config, Box, Text } from 'folds';
|
||||
import { useAtomValue, useSetAtom } from 'jotai';
|
||||
import { logoutClient } from '$client/initMatrix';
|
||||
import { activeSessionIdAtom, sessionsAtom } from '$state/sessions';
|
||||
@@ -11,6 +11,8 @@ import {
|
||||
VerificationStatus,
|
||||
} from '$hooks/useDeviceVerificationStatus';
|
||||
import { InfoCard } from './info-card';
|
||||
import { AsyncError } from '$components/AsyncError';
|
||||
import { Button } from '$components/button';
|
||||
|
||||
type LogoutDialogProps = {
|
||||
handleClose: () => void;
|
||||
@@ -78,17 +80,14 @@ export const LogoutDialog = forwardRef<HTMLDivElement, LogoutDialogProps>(
|
||||
/>
|
||||
))}
|
||||
<Text priority="400">You’re about to log out. Are you sure?</Text>
|
||||
{logoutState.status === AsyncStatus.Error && (
|
||||
<Text style={{ color: color.Critical.Main }} size="T300">
|
||||
Failed to logout! {logoutState.error.message}
|
||||
</Text>
|
||||
)}
|
||||
<AsyncError state={logoutState} prefix="Failed to logout" size="T300" />
|
||||
<Box direction="Column" gap="200">
|
||||
<Button
|
||||
variant="Critical"
|
||||
onClick={logout}
|
||||
disabled={ongoingLogout}
|
||||
before={ongoingLogout && <Spinner variant="Critical" fill="Solid" size="200" />}
|
||||
loading={ongoingLogout}
|
||||
spinnerVariant="Critical"
|
||||
spinnerSize="200"
|
||||
>
|
||||
<Text size="B400">Logout</Text>
|
||||
</Button>
|
||||
|
||||
@@ -9,6 +9,7 @@ import { storePrivateKey } from '$client/secretStorageKeys';
|
||||
import { stopPropagation } from '$utils/keyboard';
|
||||
import { useMatrixClient } from '$hooks/useMatrixClient';
|
||||
import { AsyncStatus, useAsyncCallback } from '$hooks/useAsyncCallback';
|
||||
import { AsyncError } from '$components/AsyncError';
|
||||
import { SettingTile } from './setting-tile';
|
||||
import { SecretStorageRecoveryKey, SecretStorageRecoveryPassphrase } from './SecretStorage';
|
||||
|
||||
@@ -178,11 +179,7 @@ export function ManualVerificationTile({
|
||||
onDecodedRecoveryKey={handleDecodedRecoveryKey}
|
||||
/>
|
||||
)}
|
||||
{verifyState.status === AsyncStatus.Error && (
|
||||
<Text size="T200" style={{ color: color.Critical.Main }}>
|
||||
<b>{verifyState.error.message}</b>
|
||||
</Text>
|
||||
)}
|
||||
<AsyncError state={verifyState} bold />
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
import { render } from '@testing-library/react';
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import { ScreenSize, ScreenSizeProvider } from '$hooks/useScreenSize';
|
||||
import { Modal500 } from './Modal500';
|
||||
|
||||
describe('Modal500', () => {
|
||||
it('does not throw when rendered without tabbable children', () => {
|
||||
expect(() =>
|
||||
render(
|
||||
<ScreenSizeProvider value={ScreenSize.Desktop}>
|
||||
<Modal500 requestClose={vi.fn<() => void>()}>
|
||||
<div>Empty modal content</div>
|
||||
</Modal500>
|
||||
</ScreenSizeProvider>
|
||||
)
|
||||
).not.toThrow();
|
||||
});
|
||||
});
|
||||
@@ -1,22 +0,0 @@
|
||||
import type { ReactNode } from 'react';
|
||||
import { useRef } from 'react';
|
||||
import { Modal } from 'folds';
|
||||
import { ModalOverlay } from '$components/modal-overlay/ModalOverlay';
|
||||
|
||||
type Modal500Props = {
|
||||
requestClose: () => void;
|
||||
children: ReactNode;
|
||||
};
|
||||
|
||||
/** A size-500 modal on desktop that fills the viewport on a phone. */
|
||||
export function Modal500({ requestClose, children }: Modal500Props) {
|
||||
const modalRef = useRef<HTMLDivElement | null>(null);
|
||||
|
||||
return (
|
||||
<ModalOverlay requestClose={requestClose} mobile="fullscreen" contentRef={modalRef}>
|
||||
<Modal ref={modalRef} tabIndex={-1} size="500" variant="Background">
|
||||
{children}
|
||||
</Modal>
|
||||
</ModalOverlay>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
import { globalStyle, style } from '@vanilla-extract/css';
|
||||
import { config, toRem } from 'folds';
|
||||
|
||||
export const SheetContent = style({
|
||||
width: '100%',
|
||||
maxHeight: '100%',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
});
|
||||
|
||||
// Targets the caller's menu element, which may be any component. Reaching it by
|
||||
// selector rather than cloneElement keeps it working when the caller does not
|
||||
// forward className.
|
||||
globalStyle(`${SheetContent} > *:last-child`, {
|
||||
// !important beats the inline maxWidth/width the callers set for their desktop popout.
|
||||
width: '100% !important',
|
||||
maxWidth: 'none !important',
|
||||
maxHeight: '100%',
|
||||
position: 'relative',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
borderBottomLeftRadius: '0 !important',
|
||||
borderBottomRightRadius: '0 !important',
|
||||
borderBottom: 'none !important',
|
||||
borderTopLeftRadius: `${toRem(20)} !important`,
|
||||
borderTopRightRadius: `${toRem(20)} !important`,
|
||||
paddingBottom: `calc(${config.space.S400} + var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px))) !important`,
|
||||
});
|
||||
|
||||
globalStyle(`${SheetContent} > *:last-child::after`, {
|
||||
content: '""',
|
||||
position: 'absolute',
|
||||
top: '100%',
|
||||
left: 0,
|
||||
right: 0,
|
||||
height: '300px',
|
||||
backgroundColor: 'inherit',
|
||||
border: 'none',
|
||||
});
|
||||
@@ -0,0 +1,241 @@
|
||||
// oxlint-disable typescript/no-explicit-any
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest';
|
||||
import { cleanup, render, screen } from '@testing-library/react';
|
||||
import { ScreenSize, ScreenSizeProvider } from '$hooks/useScreenSize';
|
||||
import { ResponsiveMenu } from './ResponsiveMenu';
|
||||
import type { RectCords } from 'folds';
|
||||
|
||||
// ── Mocks ───────────────────────────────────────────────────────────────────
|
||||
|
||||
vi.mock('folds', () => ({
|
||||
Box: ({ children, direction }: any) => (
|
||||
<div data-testid="box" data-direction={direction}>
|
||||
{children}
|
||||
</div>
|
||||
),
|
||||
PopOut: ({ content, children, 'aria-expanded': ariaExpanded }: any) => (
|
||||
<div data-testid="popout" data-aria-expanded={ariaExpanded}>
|
||||
<div data-testid="popout-content">{content}</div>
|
||||
<div data-testid="popout-trigger">{children}</div>
|
||||
</div>
|
||||
),
|
||||
}));
|
||||
|
||||
vi.mock('focus-trap-react', () => ({
|
||||
default: ({ children, focusTrapOptions }: any) => (
|
||||
<div
|
||||
data-testid="focus-trap"
|
||||
data-initial-focus={String(focusTrapOptions?.initialFocus ?? false)}
|
||||
data-return-focus={String(focusTrapOptions?.returnFocusOnDeactivate ?? false)}
|
||||
data-click-outside={String(focusTrapOptions?.clickOutsideDeactivates ?? false)}
|
||||
data-escape-deactivates={String(focusTrapOptions?.escapeDeactivates ?? false)}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
),
|
||||
}));
|
||||
|
||||
vi.mock('./MobileSwipeDownModal', () => ({
|
||||
MobileSwipeDownModal: ({ children, requestClose }: any) => (
|
||||
<div data-testid="mobile-swipe-down" data-request-close={String(!!requestClose)}>
|
||||
{children(<div data-testid="drag-handle">drag-handle</div>, {
|
||||
onTouchStart: vi.fn<() => void>(),
|
||||
onTouchMove: vi.fn<() => void>(),
|
||||
onTouchEnd: vi.fn<() => void>(),
|
||||
})}
|
||||
</div>
|
||||
),
|
||||
}));
|
||||
|
||||
vi.mock('$features/room/message/styles.css', () => ({
|
||||
MessageOptionsMenu: 'mock-message-options-menu',
|
||||
}));
|
||||
|
||||
vi.mock('$utils/keyboard', () => ({
|
||||
stopPropagation: () => false,
|
||||
}));
|
||||
|
||||
afterEach(() => {
|
||||
cleanup();
|
||||
});
|
||||
|
||||
// ── Helper: render wrapped in a ScreenSizeProvider ──────────────────────────
|
||||
|
||||
function renderMenu(props: {
|
||||
anchor: RectCords;
|
||||
menu: React.ReactNode;
|
||||
children?: React.ReactNode;
|
||||
returnFocusOnDeactivate?: boolean;
|
||||
}) {
|
||||
return render(
|
||||
<ScreenSizeProvider value={ScreenSize.Desktop}>
|
||||
<ResponsiveMenu requestClose={vi.fn<() => void>()} {...props} />
|
||||
</ScreenSizeProvider>
|
||||
);
|
||||
}
|
||||
|
||||
function renderMenuMobile(props: {
|
||||
anchor: RectCords;
|
||||
menu: React.ReactNode;
|
||||
children?: React.ReactNode;
|
||||
}) {
|
||||
return render(
|
||||
<ScreenSizeProvider value={ScreenSize.Mobile}>
|
||||
<ResponsiveMenu requestClose={vi.fn<() => void>()} {...props} />
|
||||
</ScreenSizeProvider>
|
||||
);
|
||||
}
|
||||
|
||||
const anchorRect: RectCords = { x: 100, y: 200, width: 80, height: 40 };
|
||||
|
||||
const SampleMenu = () => <div data-testid="sample-menu">Menu Items</div>;
|
||||
|
||||
// ── Tests ───────────────────────────────────────────────────────────────────
|
||||
|
||||
describe('ResponsiveMenu', () => {
|
||||
describe('desktop branch (PopOut)', () => {
|
||||
it('renders the trigger children and the menu inside PopOut when anchor is set', () => {
|
||||
renderMenu({
|
||||
anchor: anchorRect,
|
||||
menu: <SampleMenu />,
|
||||
children: <button data-testid="trigger-btn">Menu</button>,
|
||||
});
|
||||
|
||||
expect(screen.getByTestId('trigger-btn')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('popout')).toHaveAttribute('data-aria-expanded', 'true');
|
||||
// Menu should be inside the popout content
|
||||
expect(screen.getByTestId('sample-menu')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('hides the menu content when anchor is undefined (gate)', () => {
|
||||
render(
|
||||
<ScreenSizeProvider value={ScreenSize.Desktop}>
|
||||
<ResponsiveMenu
|
||||
requestClose={vi.fn<() => void>()}
|
||||
anchor={undefined}
|
||||
menu={<SampleMenu />}
|
||||
>
|
||||
<button data-testid="trigger-btn">Menu</button>
|
||||
</ResponsiveMenu>
|
||||
</ScreenSizeProvider>
|
||||
);
|
||||
|
||||
expect(screen.getByTestId('trigger-btn')).toBeInTheDocument();
|
||||
// The menu should NOT be in the DOM because anchor is undefined
|
||||
expect(screen.queryByTestId('sample-menu')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('wraps the menu in a FocusTrap on desktop', () => {
|
||||
renderMenu({
|
||||
anchor: anchorRect,
|
||||
menu: <SampleMenu />,
|
||||
});
|
||||
|
||||
expect(screen.getByTestId('focus-trap')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('sample-menu')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('honours returnFocusOnDeactivate', () => {
|
||||
render(
|
||||
<ScreenSizeProvider value={ScreenSize.Desktop}>
|
||||
<ResponsiveMenu
|
||||
requestClose={vi.fn<() => void>()}
|
||||
anchor={anchorRect}
|
||||
menu={<SampleMenu />}
|
||||
returnFocusOnDeactivate={true}
|
||||
/>
|
||||
</ScreenSizeProvider>
|
||||
);
|
||||
|
||||
expect(screen.getByTestId('focus-trap')).toHaveAttribute('data-return-focus', 'true');
|
||||
});
|
||||
|
||||
it('passes clickOutsideDeactivates to FocusTrap', () => {
|
||||
renderMenu({ anchor: anchorRect, menu: <SampleMenu /> });
|
||||
|
||||
expect(screen.getByTestId('focus-trap')).toHaveAttribute('data-click-outside', 'true');
|
||||
});
|
||||
});
|
||||
|
||||
describe('mobile branch (sheet)', () => {
|
||||
it('renders a MobileSwipeDownModal with drag handle on mobile', () => {
|
||||
renderMenuMobile({ anchor: anchorRect, menu: <SampleMenu /> });
|
||||
|
||||
expect(screen.getByTestId('mobile-swipe-down')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('drag-handle')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('does not render the sheet when anchor is undefined', () => {
|
||||
render(
|
||||
<ScreenSizeProvider value={ScreenSize.Mobile}>
|
||||
<ResponsiveMenu
|
||||
requestClose={vi.fn<() => void>()}
|
||||
anchor={undefined}
|
||||
menu={<SampleMenu />}
|
||||
>
|
||||
<button data-testid="trigger-btn">Menu</button>
|
||||
</ResponsiveMenu>
|
||||
</ScreenSizeProvider>
|
||||
);
|
||||
|
||||
expect(screen.getByTestId('trigger-btn')).toBeInTheDocument();
|
||||
expect(screen.queryByTestId('mobile-swipe-down')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('wraps the menu in a FocusTrap on mobile', () => {
|
||||
renderMenuMobile({ anchor: anchorRect, menu: <SampleMenu /> });
|
||||
|
||||
expect(screen.getByTestId('focus-trap')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('sample-menu')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders menu children inside the mobile sheet', () => {
|
||||
renderMenuMobile({ anchor: anchorRect, menu: <SampleMenu /> });
|
||||
|
||||
// The SampleMenu is rendered inside the sheet
|
||||
expect(screen.getByTestId('sample-menu')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('mobile-swipe-down')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('drag-handle')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('focus-trap')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
describe('escape closes on both branches', () => {
|
||||
it('passes escapeDeactivates callback to FocusTrap on desktop', () => {
|
||||
renderMenu({ anchor: anchorRect, menu: <SampleMenu /> });
|
||||
|
||||
// stopPropagation returns false — it's a function, so the attribute
|
||||
// serializes as either 'false' (boolean) or the function string.
|
||||
// FocusTrap receives it — verify the FocusTrap is present with
|
||||
// a non-empty escapeDeactivates.
|
||||
const trap = screen.getByTestId('focus-trap');
|
||||
const escapeAttr = trap.getAttribute('data-escape-deactivates');
|
||||
expect(escapeAttr).toBeTruthy();
|
||||
});
|
||||
|
||||
it('wires requestClose as onDeactivate on mobile too', () => {
|
||||
const requestClose = vi.fn<() => void>();
|
||||
render(
|
||||
<ScreenSizeProvider value={ScreenSize.Mobile}>
|
||||
<ResponsiveMenu requestClose={requestClose} anchor={anchorRect} menu={<SampleMenu />} />
|
||||
</ScreenSizeProvider>
|
||||
);
|
||||
|
||||
expect(screen.getByTestId('mobile-swipe-down')).toHaveAttribute('data-request-close', 'true');
|
||||
});
|
||||
});
|
||||
|
||||
describe('initialFocus', () => {
|
||||
it('has initialFocus=false by default on desktop', () => {
|
||||
renderMenu({ anchor: anchorRect, menu: <SampleMenu /> });
|
||||
|
||||
expect(screen.getByTestId('focus-trap')).toHaveAttribute('data-initial-focus', 'false');
|
||||
});
|
||||
|
||||
it('has initialFocus=false by default on mobile', () => {
|
||||
renderMenuMobile({ anchor: anchorRect, menu: <SampleMenu /> });
|
||||
|
||||
expect(screen.getByTestId('focus-trap')).toHaveAttribute('data-initial-focus', 'false');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,22 +1,11 @@
|
||||
import type { ReactNode } from 'react';
|
||||
import type { RectCords } from 'folds';
|
||||
import { PopOut } from 'folds';
|
||||
import { Box, PopOut } from 'folds';
|
||||
import FocusTrap from 'focus-trap-react';
|
||||
import { ScreenSize, useScreenSizeOptionally } from '$hooks/useScreenSize';
|
||||
import { stopPropagation } from '$utils/keyboard';
|
||||
import { MobileSwipeDownModal } from './MobileSwipeDownModal';
|
||||
|
||||
type DragHandlers = {
|
||||
onTouchStart: (e: React.TouchEvent) => void;
|
||||
onTouchMove: (e: React.TouchEvent) => void;
|
||||
onTouchEnd: () => void;
|
||||
};
|
||||
|
||||
/**
|
||||
* Given the sheet's drag handle on mobile, and nothing on desktop. Only
|
||||
* `RoomViewHeader` needs this; every other menu passes a plain node.
|
||||
*/
|
||||
type MenuRenderer = (dragHandle: ReactNode, dragHandlers: DragHandlers | undefined) => ReactNode;
|
||||
import * as css from './ResponsiveMenu.css';
|
||||
|
||||
type ComponentPosition = 'Top' | 'Right' | 'Bottom' | 'Left';
|
||||
type ComponentAlign = 'Start' | 'Center' | 'End';
|
||||
@@ -24,7 +13,7 @@ type ComponentAlign = 'Start' | 'Center' | 'End';
|
||||
type ResponsiveMenuProps = {
|
||||
anchor: RectCords | undefined;
|
||||
requestClose: () => void;
|
||||
menu: ReactNode | MenuRenderer;
|
||||
menu: ReactNode;
|
||||
/** The element the menu hangs off on desktop. */
|
||||
children?: ReactNode;
|
||||
position?: ComponentPosition;
|
||||
@@ -79,9 +68,17 @@ export function ResponsiveMenu({
|
||||
<MobileSwipeDownModal requestClose={requestClose}>
|
||||
{(dragHandle, dragHandlers) => (
|
||||
<FocusTrap focusTrapOptions={focusTrapOptions}>
|
||||
<div role="dialog" aria-modal="true">
|
||||
{typeof menu === 'function' ? menu(dragHandle, dragHandlers) : menu}
|
||||
</div>
|
||||
<Box
|
||||
direction="Column"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
className={css.SheetContent}
|
||||
// Swiping anywhere on the sheet dismisses it, not just the handle.
|
||||
{...dragHandlers}
|
||||
>
|
||||
{dragHandle}
|
||||
{menu}
|
||||
</Box>
|
||||
</FocusTrap>
|
||||
)}
|
||||
</MobileSwipeDownModal>
|
||||
@@ -100,11 +97,7 @@ export function ResponsiveMenu({
|
||||
content={
|
||||
// Gated so a call site that builds its menu inline does that work on open,
|
||||
// not on every render of the trigger.
|
||||
anchor ? (
|
||||
<FocusTrap focusTrapOptions={focusTrapOptions}>
|
||||
{typeof menu === 'function' ? menu(null, undefined) : menu}
|
||||
</FocusTrap>
|
||||
) : null
|
||||
anchor ? <FocusTrap focusTrapOptions={focusTrapOptions}>{menu}</FocusTrap> : null
|
||||
}
|
||||
>
|
||||
{children}
|
||||
|
||||
@@ -6,7 +6,7 @@ import { useMatrixClient } from '$hooks/useMatrixClient';
|
||||
import type { LocalRoomSummary } from '$hooks/useLocalRoomSummary';
|
||||
import { useLocalRoomSummary } from '$hooks/useLocalRoomSummary';
|
||||
|
||||
export type IRoomSummary = Awaited<ReturnType<MatrixClient['getRoomSummary']>>;
|
||||
type IRoomSummary = Awaited<ReturnType<MatrixClient['getRoomSummary']>>;
|
||||
|
||||
type RoomSummaryLoaderProps = {
|
||||
roomIdOrAlias: string;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { FormEventHandler } from 'react';
|
||||
import { useCallback } from 'react';
|
||||
import { Box, Text, Button, Spinner, color } from 'folds';
|
||||
import { Box, Text } from 'folds';
|
||||
import { decodeRecoveryKey, deriveRecoveryKeyFromPassphrase } from '$types/matrix-sdk';
|
||||
import type {
|
||||
SecretStorageKeyContent,
|
||||
@@ -8,8 +8,10 @@ import type {
|
||||
} from '$types/matrix/accountData';
|
||||
import { AsyncStatus, useAsyncCallback } from '$hooks/useAsyncCallback';
|
||||
import { useMatrixClient } from '$hooks/useMatrixClient';
|
||||
import { AsyncError } from '$components/AsyncError';
|
||||
import { useAlive } from '$hooks/useAlive';
|
||||
import { PasswordInput } from './password-input';
|
||||
import { Button } from '$components/button';
|
||||
|
||||
type SecretStorageRecoveryPassphraseProps = {
|
||||
processing?: boolean;
|
||||
@@ -96,8 +98,9 @@ export function SecretStorageRecoveryPassphrase({
|
||||
variant="Success"
|
||||
size="400"
|
||||
radii="300"
|
||||
disabled={loading}
|
||||
before={loading && <Spinner size="200" variant="Success" fill="Solid" />}
|
||||
loading={loading}
|
||||
spinnerSize="200"
|
||||
spinnerVariant="Success"
|
||||
>
|
||||
<Text as="span" size="B400">
|
||||
Verify
|
||||
@@ -105,11 +108,7 @@ export function SecretStorageRecoveryPassphrase({
|
||||
</Button>
|
||||
</Box>
|
||||
</Box>
|
||||
{driveKeyState.status === AsyncStatus.Error && (
|
||||
<Text size="T200" style={{ color: color.Critical.Main }}>
|
||||
<b>{driveKeyState.error.message}</b>
|
||||
</Text>
|
||||
)}
|
||||
<AsyncError state={driveKeyState} bold />
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
@@ -186,8 +185,9 @@ export function SecretStorageRecoveryKey({
|
||||
variant="Success"
|
||||
size="400"
|
||||
radii="300"
|
||||
disabled={loading}
|
||||
before={loading && <Spinner size="200" variant="Success" fill="Solid" />}
|
||||
loading={loading}
|
||||
spinnerSize="200"
|
||||
spinnerVariant="Success"
|
||||
>
|
||||
<Text as="span" size="B400">
|
||||
Verify
|
||||
@@ -195,11 +195,7 @@ export function SecretStorageRecoveryKey({
|
||||
</Button>
|
||||
</Box>
|
||||
</Box>
|
||||
{driveKeyState.status === AsyncStatus.Error && (
|
||||
<Text size="T200" style={{ color: color.Critical.Main }}>
|
||||
<b>{driveKeyState.error.message}</b>
|
||||
</Text>
|
||||
)}
|
||||
<AsyncError state={driveKeyState} bold />
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
import { type ReactNode, useCallback, useMemo, useState } from 'react';
|
||||
import { Box, Text, Button, Modal } from 'folds';
|
||||
import { SettingTile } from '$components/setting-tile';
|
||||
import { useObjectURL } from '$hooks/useObjectURL';
|
||||
import type { UploadSuccess } from '$state/upload';
|
||||
import { createUploadAtom } from '$state/upload';
|
||||
import { useFilePicker } from '$hooks/useFilePicker';
|
||||
import { CompactUploadCardRenderer } from '$components/upload-card';
|
||||
import { ImageEditor } from '$components/image-editor';
|
||||
import { ModalWide } from '$styles/Modal.css';
|
||||
import { ModalOverlay } from '$components/modal-overlay/ModalOverlay';
|
||||
import { confirm } from '$components/confirm/confirm';
|
||||
|
||||
export type AvatarUploadTileProps = {
|
||||
title: string;
|
||||
focusId?: string;
|
||||
after: ReactNode;
|
||||
disableSetAvatar?: boolean;
|
||||
removeDisabled?: boolean;
|
||||
onUpload: (mxc: string) => void;
|
||||
onRemove: () => void;
|
||||
confirmTitle: string;
|
||||
confirmDescription: string;
|
||||
};
|
||||
|
||||
export function AvatarUploadTile({
|
||||
title,
|
||||
focusId,
|
||||
after,
|
||||
disableSetAvatar = false,
|
||||
removeDisabled = false,
|
||||
onUpload,
|
||||
onRemove,
|
||||
confirmTitle,
|
||||
confirmDescription,
|
||||
}: AvatarUploadTileProps) {
|
||||
const [imageFile, setImageFile] = useState<File>();
|
||||
const imageFileURL = useObjectURL(imageFile);
|
||||
const uploadAtom = useMemo(() => {
|
||||
if (imageFile) return createUploadAtom(imageFile);
|
||||
return undefined;
|
||||
}, [imageFile]);
|
||||
|
||||
const pickFile = useFilePicker(setImageFile, false);
|
||||
|
||||
const handleRemoveUpload = useCallback(() => {
|
||||
setImageFile(undefined);
|
||||
}, []);
|
||||
|
||||
const handleUploaded = useCallback(
|
||||
(upload: UploadSuccess) => {
|
||||
onUpload(upload.mxc);
|
||||
handleRemoveUpload();
|
||||
},
|
||||
[onUpload, handleRemoveUpload]
|
||||
);
|
||||
|
||||
const handleRemoveAvatar = useCallback(async () => {
|
||||
const ok = await confirm({
|
||||
title: confirmTitle,
|
||||
description: confirmDescription,
|
||||
action: 'Remove',
|
||||
variant: 'Critical',
|
||||
});
|
||||
if (ok) {
|
||||
onRemove();
|
||||
}
|
||||
}, [confirmTitle, confirmDescription, onRemove]);
|
||||
|
||||
return (
|
||||
<SettingTile title={title} focusId={focusId} after={after}>
|
||||
{uploadAtom ? (
|
||||
<Box gap="200" direction="Column">
|
||||
<CompactUploadCardRenderer
|
||||
uploadAtom={uploadAtom}
|
||||
onRemove={handleRemoveUpload}
|
||||
onComplete={handleUploaded}
|
||||
/>
|
||||
</Box>
|
||||
) : (
|
||||
<Box gap="200">
|
||||
<Button
|
||||
onClick={() => pickFile('image/*')}
|
||||
size="300"
|
||||
variant="Secondary"
|
||||
fill="Soft"
|
||||
outlined
|
||||
radii="300"
|
||||
disabled={disableSetAvatar}
|
||||
>
|
||||
<Text size="B300">Upload</Text>
|
||||
</Button>
|
||||
{!removeDisabled && (
|
||||
<Button
|
||||
size="300"
|
||||
variant="Critical"
|
||||
fill="None"
|
||||
radii="300"
|
||||
disabled={disableSetAvatar}
|
||||
onClick={handleRemoveAvatar}
|
||||
>
|
||||
<Text size="B300">Remove</Text>
|
||||
</Button>
|
||||
)}
|
||||
</Box>
|
||||
)}
|
||||
|
||||
{imageFileURL && (
|
||||
<ModalOverlay open={false} requestClose={handleRemoveUpload}>
|
||||
<Modal className={ModalWide} variant="Surface" size="500">
|
||||
<ImageEditor
|
||||
name={imageFile?.name ?? 'Unnamed'}
|
||||
url={imageFileURL}
|
||||
requestClose={handleRemoveUpload}
|
||||
/>
|
||||
</Modal>
|
||||
</ModalOverlay>
|
||||
)}
|
||||
</SettingTile>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
import type { ComplexStyleRule } from '@vanilla-extract/css';
|
||||
import { createVar } from '@vanilla-extract/css';
|
||||
import type { RecipeVariants } from '@vanilla-extract/recipes';
|
||||
import { recipe } from '@vanilla-extract/recipes';
|
||||
import { color, config, toRem, DefaultReset, Disabled, FocusOutline, RadiiVariant } from 'folds';
|
||||
|
||||
type MainColor = 'Primary' | 'Secondary' | 'Success' | 'Warning' | 'Critical';
|
||||
|
||||
const Main = createVar();
|
||||
const MainHover = createVar();
|
||||
const MainActive = createVar();
|
||||
const MainLine = createVar();
|
||||
const OnMain = createVar();
|
||||
const Container = createVar();
|
||||
const ContainerHover = createVar();
|
||||
const ContainerActive = createVar();
|
||||
const ContainerLine = createVar();
|
||||
const OnContainer = createVar();
|
||||
|
||||
const Hover = createVar();
|
||||
const Active = createVar();
|
||||
const UIBeforeAfterSpace = createVar();
|
||||
|
||||
const getVariant = (variant: MainColor): ComplexStyleRule => ({
|
||||
vars: {
|
||||
[Main]: color[variant].Main,
|
||||
[MainHover]: color[variant].MainHover,
|
||||
[MainActive]: color[variant].MainActive,
|
||||
[MainLine]: color[variant].MainLine,
|
||||
[OnMain]: color[variant].OnMain,
|
||||
[Container]: color[variant].Container,
|
||||
[ContainerHover]: color[variant].ContainerHover,
|
||||
[ContainerActive]: color[variant].ContainerActive,
|
||||
[ContainerLine]: color[variant].ContainerLine,
|
||||
[OnContainer]: color[variant].OnContainer,
|
||||
},
|
||||
});
|
||||
|
||||
export const Button = recipe({
|
||||
base: [
|
||||
DefaultReset,
|
||||
{
|
||||
minWidth: 0,
|
||||
maxWidth: '100%',
|
||||
display: 'inline-flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
cursor: 'pointer',
|
||||
|
||||
selectors: {
|
||||
'&[aria-pressed=true]': {
|
||||
backgroundColor: Active,
|
||||
},
|
||||
'&:hover, &:focus-visible': {
|
||||
backgroundColor: Hover,
|
||||
},
|
||||
'&:active': {
|
||||
backgroundColor: Active,
|
||||
},
|
||||
'&[data-ui-before=true]': {
|
||||
paddingLeft: [UIBeforeAfterSpace],
|
||||
},
|
||||
'&[data-ui-after=true]': {
|
||||
paddingRight: [UIBeforeAfterSpace],
|
||||
},
|
||||
},
|
||||
},
|
||||
FocusOutline,
|
||||
Disabled,
|
||||
],
|
||||
variants: {
|
||||
size: {
|
||||
'300': {
|
||||
vars: {
|
||||
[UIBeforeAfterSpace]: config.space.S200,
|
||||
},
|
||||
height: toRem(32),
|
||||
gap: config.space.S100,
|
||||
padding: `0 ${config.space.S300}`,
|
||||
},
|
||||
'400': {
|
||||
vars: {
|
||||
[UIBeforeAfterSpace]: config.space.S300,
|
||||
},
|
||||
height: toRem(40),
|
||||
gap: config.space.S200,
|
||||
padding: `0 ${config.space.S400}`,
|
||||
},
|
||||
'500': {
|
||||
vars: {
|
||||
[UIBeforeAfterSpace]: config.space.S400,
|
||||
},
|
||||
height: toRem(48),
|
||||
gap: config.space.S300,
|
||||
padding: `0 ${config.space.S500}`,
|
||||
},
|
||||
},
|
||||
variant: {
|
||||
Primary: getVariant('Primary'),
|
||||
Secondary: getVariant('Secondary'),
|
||||
Success: getVariant('Success'),
|
||||
Warning: getVariant('Warning'),
|
||||
Critical: getVariant('Critical'),
|
||||
},
|
||||
fill: {
|
||||
Solid: {
|
||||
vars: {
|
||||
[Hover]: MainHover,
|
||||
[Active]: MainActive,
|
||||
},
|
||||
backgroundColor: Main,
|
||||
color: OnMain,
|
||||
borderColor: MainLine,
|
||||
},
|
||||
Soft: {
|
||||
vars: {
|
||||
[Hover]: ContainerHover,
|
||||
[Active]: ContainerActive,
|
||||
},
|
||||
backgroundColor: Container,
|
||||
color: OnContainer,
|
||||
borderColor: ContainerLine,
|
||||
},
|
||||
None: {
|
||||
vars: {
|
||||
[Hover]: ContainerHover,
|
||||
[Active]: ContainerActive,
|
||||
},
|
||||
backgroundColor: 'inherit',
|
||||
color: Main,
|
||||
borderColor: Main,
|
||||
},
|
||||
},
|
||||
outlined: {
|
||||
true: {
|
||||
borderWidth: config.borderWidth.B400,
|
||||
},
|
||||
},
|
||||
radii: RadiiVariant,
|
||||
},
|
||||
defaultVariants: {
|
||||
size: '400',
|
||||
variant: 'Primary',
|
||||
fill: 'Solid',
|
||||
radii: '400',
|
||||
},
|
||||
});
|
||||
|
||||
export type ButtonVariants = RecipeVariants<typeof Button>;
|
||||
@@ -0,0 +1,63 @@
|
||||
import type { ReactNode } from 'react';
|
||||
import classNames from 'classnames';
|
||||
import { as, Spinner } from 'folds';
|
||||
import * as css from './Button.css';
|
||||
|
||||
type SpinnerProps = {
|
||||
/** Swaps `before` for a spinner and disables the button. */
|
||||
loading?: boolean;
|
||||
spinnerVariant?: 'Primary' | 'Secondary' | 'Success' | 'Warning' | 'Critical';
|
||||
spinnerFill?: 'Solid' | 'Soft';
|
||||
spinnerSize?: '50' | '100' | '200' | '300' | '400' | '500' | '600' | 'Inherit';
|
||||
};
|
||||
|
||||
type ButtonProps = SpinnerProps & {
|
||||
before?: ReactNode;
|
||||
after?: ReactNode;
|
||||
};
|
||||
|
||||
export const Button = as<'button', css.ButtonVariants & ButtonProps>(
|
||||
(
|
||||
{
|
||||
as: AsButton = 'button',
|
||||
className,
|
||||
size,
|
||||
variant,
|
||||
fill,
|
||||
outlined,
|
||||
radii,
|
||||
before,
|
||||
after,
|
||||
loading,
|
||||
spinnerVariant = 'Primary',
|
||||
spinnerFill = 'Solid',
|
||||
spinnerSize = '200',
|
||||
disabled,
|
||||
children,
|
||||
...props
|
||||
},
|
||||
ref
|
||||
) => {
|
||||
const leading = loading ? (
|
||||
<Spinner variant={spinnerVariant} fill={spinnerFill} size={spinnerSize} />
|
||||
) : (
|
||||
before
|
||||
);
|
||||
|
||||
return (
|
||||
<AsButton
|
||||
className={classNames(css.Button({ size, variant, fill, outlined, radii }), className)}
|
||||
data-ui-before={leading ? true : undefined}
|
||||
data-ui-after={after ? true : undefined}
|
||||
disabled={loading || disabled}
|
||||
aria-busy={loading || undefined}
|
||||
{...props}
|
||||
ref={ref}
|
||||
>
|
||||
{leading}
|
||||
{children}
|
||||
{after}
|
||||
</AsButton>
|
||||
);
|
||||
}
|
||||
);
|
||||
@@ -0,0 +1 @@
|
||||
export * from './Button';
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Box, Button, Spinner, Text, color, config } from 'folds';
|
||||
import { Box, Text, color, config } from 'folds';
|
||||
import { PromptDialog } from '$components/modal-overlay/PromptDialog';
|
||||
import { Button } from '$components/button';
|
||||
|
||||
type DirectInvitePromptProps = {
|
||||
onCancel: () => void;
|
||||
@@ -34,8 +35,9 @@ export function DirectInvitePrompt({
|
||||
<Button
|
||||
variant="Primary"
|
||||
onClick={onConvertAndInvite}
|
||||
disabled={converting}
|
||||
before={converting ? <Spinner fill="Solid" variant="Primary" size="200" /> : undefined}
|
||||
loading={converting}
|
||||
spinnerVariant="Primary"
|
||||
spinnerSize="200"
|
||||
aria-disabled={converting}
|
||||
>
|
||||
<Text size="B400">
|
||||
|
||||
@@ -60,7 +60,7 @@ const insertPastedText = (editor: Editor, text: string): void => {
|
||||
});
|
||||
};
|
||||
|
||||
export type EditorChangeHandler = (value: Descendant[]) => void;
|
||||
type EditorChangeHandler = (value: Descendant[]) => void;
|
||||
const MAX_MULTILINE_MEASURE_RETRIES = 2;
|
||||
const MULTILINE_HEIGHT_EPSILON = 1;
|
||||
const TRAILING_SPACE_SENTINEL = '\u200B';
|
||||
|
||||
@@ -7,7 +7,7 @@ import type { MatrixClient } from '$types/matrix-sdk';
|
||||
import { JoinRule } from '$types/matrix-sdk';
|
||||
import { useAtomValue } from 'jotai';
|
||||
|
||||
import { getDirectRoomAvatarUrl } from '$utils/room';
|
||||
import { getDirectRoomAvatarUrl } from '$utils/room/display';
|
||||
import { useMatrixClient } from '$hooks/useMatrixClient';
|
||||
import { isRoomAlias } from '$utils/matrix';
|
||||
import { useAsyncSearch } from '$hooks/useAsyncSearch';
|
||||
|
||||
@@ -12,7 +12,7 @@ import { useAsyncSearch } from '$hooks/useAsyncSearch';
|
||||
import { onTabPress } from '$utils/keyboard';
|
||||
import { useKeyDown } from '$hooks/useKeyDown';
|
||||
import { getMxIdLocalPart, isUserId } from '$utils/matrix';
|
||||
import { getAvatarUrl, getMemberDisplayName, getMemberSearchStr } from '$utils/room';
|
||||
import { getAvatarUrl, getMemberDisplayName, getMemberSearchStr } from '$utils/room/display';
|
||||
import { UserAvatar } from '$components/user-avatar';
|
||||
import { useMediaAuthentication } from '$hooks/useMediaAuthentication';
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import { sanitizeText } from '$utils/sanitize';
|
||||
import { markdownToHtml, injectDataMd } from '$plugins/markdown';
|
||||
import { sanitizeForRegex } from '$utils/regex';
|
||||
import { getMxIdLocalPart, isUserId } from '$utils/matrix';
|
||||
import { getMemberDisplayName } from '$utils/room';
|
||||
import { getMemberDisplayName } from '$utils/room/display';
|
||||
import type { CustomElement } from './slate';
|
||||
import { BlockType } from './types';
|
||||
import { getMarkdownCodeSpanRanges, isInsideMarkdownCodeSpan } from './utils';
|
||||
|
||||
@@ -4,7 +4,7 @@ import { ReactEditor } from 'slate-react';
|
||||
import type { Room } from '$types/matrix-sdk';
|
||||
import type { Nicknames } from '$state/nicknames';
|
||||
import { getMxIdLocalPart, isUserId } from '$utils/matrix';
|
||||
import { getMemberDisplayName } from '$utils/room';
|
||||
import { getMemberDisplayName } from '$utils/room/display';
|
||||
import { BlockType } from './types';
|
||||
import type {
|
||||
CommandElement,
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
config,
|
||||
} from 'folds';
|
||||
import type { IContent, MatrixEvent, Room } from '$types/matrix-sdk';
|
||||
import { getAvatarUrl, getMemberDisplayName } from '$utils/room';
|
||||
import { getAvatarUrl, getMemberDisplayName } from '$utils/room/display';
|
||||
import { getMxIdLocalPart } from '$utils/matrix';
|
||||
import { useMatrixClient } from '$hooks/useMatrixClient';
|
||||
import { useMediaAuthentication } from '$hooks/useMediaAuthentication';
|
||||
@@ -50,7 +50,7 @@ import { useSettingsLinkBaseUrl } from '$features/settings/useSettingsLinkBaseUr
|
||||
import * as css from './EventHistory.css';
|
||||
import { EventType } from '$types/matrix-sdk';
|
||||
|
||||
export type EventHistoryProps = {
|
||||
type EventHistoryProps = {
|
||||
room: Room;
|
||||
mEvents: MatrixEvent[];
|
||||
requestClose: () => void;
|
||||
|
||||
@@ -3,7 +3,7 @@ import { useEffect, useState } from 'react';
|
||||
import { Avatar, Box, Header, IconButton, MenuItem, Scroll, Text, as, config } from 'folds';
|
||||
import type { Room } from '$types/matrix-sdk';
|
||||
import { useRoomEventReaders } from '$hooks/useRoomEventReaders';
|
||||
import { getAvatarUrl, getMemberDisplayName } from '$utils/room';
|
||||
import { getAvatarUrl, getMemberDisplayName } from '$utils/room/display';
|
||||
import { getMxIdLocalPart } from '$utils/matrix';
|
||||
import { useMatrixClient } from '$hooks/useMatrixClient';
|
||||
import { useMediaAuthentication } from '$hooks/useMediaAuthentication';
|
||||
@@ -18,7 +18,7 @@ import { UserAvatar } from '$components/user-avatar';
|
||||
import { composerIcon, userFallbackIcon, X } from '$components/icons/phosphor';
|
||||
import * as css from './EventReaders.css';
|
||||
|
||||
export type EventReadersProps = {
|
||||
type EventReadersProps = {
|
||||
room: Room;
|
||||
eventId: string;
|
||||
requestClose: () => void;
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Box, Chip, Header, IconButton, Text, as } from 'folds';
|
||||
import { ArrowLeft, sizedIcon } from '$components/icons/phosphor';
|
||||
import * as css from './ImageEditor.css';
|
||||
|
||||
export type ImageEditorProps = {
|
||||
type ImageEditorProps = {
|
||||
name: string;
|
||||
url: string;
|
||||
requestClose: () => void;
|
||||
|
||||
@@ -19,7 +19,7 @@ import { UsageSwitcher } from './UsageSwitcher';
|
||||
import { ImagePackProfile, ImagePackProfileEdit } from './PackMeta';
|
||||
import * as css from './style.css';
|
||||
|
||||
export type ImagePackContentProps = {
|
||||
type ImagePackContentProps = {
|
||||
imagePack: ImagePack;
|
||||
canEdit?: boolean;
|
||||
onUpdate?: (packContent: PackContent) => Promise<void>;
|
||||
|
||||
@@ -26,7 +26,7 @@ import { copyImageToClipboard } from '$utils/dom';
|
||||
import { getDownloadFilename, saveFileToDevice } from '$utils/download';
|
||||
import { ResponsiveMenu } from '$components/ResponsiveMenu';
|
||||
|
||||
export type ImageViewerProps = {
|
||||
type ImageViewerProps = {
|
||||
alt: string;
|
||||
filename?: string;
|
||||
src: string;
|
||||
@@ -108,6 +108,7 @@ export const ImageViewer = as<'div', ImageViewerProps>(
|
||||
anchor={menu.anchor}
|
||||
requestClose={menu.close}
|
||||
align="Start"
|
||||
offset={0}
|
||||
menu={
|
||||
<Menu variant="Surface" style={{ maxWidth: toRem(160), width: '100vw' }}>
|
||||
<Box direction="Column" gap="100" style={{ padding: config.space.S100 }}>
|
||||
|
||||
@@ -10,9 +10,6 @@ import {
|
||||
Text,
|
||||
IconButton,
|
||||
Input,
|
||||
Button,
|
||||
Spinner,
|
||||
color,
|
||||
TextArea,
|
||||
Dialog,
|
||||
Menu,
|
||||
@@ -30,12 +27,13 @@ import type { UseAsyncSearchOptions } from '$hooks/useAsyncSearch';
|
||||
import { useAsyncSearch } from '$hooks/useAsyncSearch';
|
||||
import { highlightText, makeHighlightRegex } from '$plugins/react-custom-html-parser';
|
||||
import { AsyncStatus, useAsyncCallback } from '$hooks/useAsyncCallback';
|
||||
import { AsyncError } from '$components/AsyncError';
|
||||
import { composerIcon, X } from '$components/icons/phosphor';
|
||||
import { useMatrixClient } from '$hooks/useMatrixClient';
|
||||
import { BreakWord } from '$styles/Text.css';
|
||||
import { useAlive } from '$hooks/useAlive';
|
||||
import { getMxIdServer } from '$utils/mxIdHelper';
|
||||
import { KnownMembership } from '$types/matrix-sdk';
|
||||
import { Button } from '$components/button';
|
||||
|
||||
const SEARCH_OPTIONS: UseAsyncSearchOptions = {
|
||||
limit: 1000,
|
||||
@@ -275,15 +273,14 @@ export function InviteUserPrompt({ room, requestClose }: InviteUserProps) {
|
||||
resize="None"
|
||||
/>
|
||||
</Box>
|
||||
{inviteState.status === AsyncStatus.Error && (
|
||||
<Text size="T200" style={{ color: color.Critical.Main }} className={BreakWord}>
|
||||
<b>{inviteState.error.message}</b>
|
||||
</Text>
|
||||
)}
|
||||
<AsyncError state={inviteState} bold />
|
||||
<Button
|
||||
type="submit"
|
||||
disabled={!validUserId || inviting}
|
||||
before={inviting && <Spinner size="200" variant="Primary" fill="Solid" />}
|
||||
loading={inviting}
|
||||
spinnerSize="200"
|
||||
spinnerVariant="Primary"
|
||||
spinnerFill="Solid"
|
||||
disabled={!validUserId}
|
||||
>
|
||||
<Text size="B400">Invite</Text>
|
||||
</Button>
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
import type { FormEventHandler } from 'react';
|
||||
import { useCallback, useEffect } from 'react';
|
||||
import { config, Box, Text, Input, color, Button, Spinner } from 'folds';
|
||||
import { config, Box, Text, Input } from 'folds';
|
||||
import type { MatrixError } from '$types/matrix-sdk';
|
||||
|
||||
import { useMatrixClient } from '$hooks/useMatrixClient';
|
||||
import { AsyncStatus, useAsyncCallback } from '$hooks/useAsyncCallback';
|
||||
import { createDebugLogger } from '$utils/debugLogger';
|
||||
import { PromptDialog } from '$components/modal-overlay/PromptDialog';
|
||||
import { AsyncError } from '$components/AsyncError';
|
||||
import { Button } from '$components/button';
|
||||
|
||||
const debugLog = createDebugLogger('KnockRoomPrompt');
|
||||
|
||||
@@ -65,21 +67,15 @@ export function KnockRoomPrompt({ roomId, via, onDone, onCancel }: KnockRoomProp
|
||||
</Text>
|
||||
</Text>
|
||||
<Input name="reasonInput" variant="Background" />
|
||||
{knockState.status === AsyncStatus.Error && (
|
||||
<Text style={{ color: color.Critical.Main }} size="T300">
|
||||
Failed to knock! {knockState.error.message}
|
||||
</Text>
|
||||
)}
|
||||
<AsyncError state={knockState} prefix="Failed to knock" size="T300" />
|
||||
</Box>
|
||||
</Box>
|
||||
<Button
|
||||
type="submit"
|
||||
variant="Primary"
|
||||
before={
|
||||
knockState.status === AsyncStatus.Loading ? (
|
||||
<Spinner fill="Solid" variant="Primary" size="200" />
|
||||
) : undefined
|
||||
}
|
||||
loading={knockState.status === AsyncStatus.Loading}
|
||||
spinnerVariant="Primary"
|
||||
spinnerSize="200"
|
||||
aria-disabled={
|
||||
knockState.status === AsyncStatus.Loading || knockState.status === AsyncStatus.Success
|
||||
}
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
import { useCallback, useEffect, useMemo } from 'react';
|
||||
import { config, Box, Text, color, Button, Spinner } from 'folds';
|
||||
import { config, Box, Text } from 'folds';
|
||||
import type { MatrixError } from '$types/matrix-sdk';
|
||||
import { useMatrixClient } from '$hooks/useMatrixClient';
|
||||
import { AsyncStatus, useAsyncCallback } from '$hooks/useAsyncCallback';
|
||||
import { getJoinedSpaceChildrenSummary, getRecursiveSpaceLeaveOrder } from '$utils/room';
|
||||
import { getJoinedSpaceChildrenSummary, getRecursiveSpaceLeaveOrder } from '$utils/room/hierarchy';
|
||||
import { rateLimitedActions } from '$utils/matrix';
|
||||
import { PromptDialog } from '$components/modal-overlay/PromptDialog';
|
||||
import { AsyncError } from '$components/AsyncError';
|
||||
import { Button } from '$components/button';
|
||||
|
||||
type LeaveSpacePromptProps = {
|
||||
roomId: string;
|
||||
@@ -85,23 +87,21 @@ export function LeaveSpacePrompt({ roomId, onDone, onCancel }: LeaveSpacePromptP
|
||||
{formatJoinedContentsMessage(roomCount, subspaceCount)}
|
||||
</Text>
|
||||
)}
|
||||
{leaveState.status === AsyncStatus.Error && (
|
||||
<Text style={{ color: color.Critical.Main }} size="T300">
|
||||
Failed to leave space! {leaveState.error.message}
|
||||
</Text>
|
||||
)}
|
||||
{leaveAllState.status === AsyncStatus.Error && (
|
||||
<Text style={{ color: color.Critical.Main }} size="T300">
|
||||
Failed to leave space, rooms, and subspaces! {leaveAllState.error.message}
|
||||
</Text>
|
||||
)}
|
||||
<AsyncError state={leaveState} prefix="Failed to leave space" size="T300" />
|
||||
<AsyncError
|
||||
state={leaveAllState}
|
||||
prefix="Failed to leave space, rooms, and subspaces"
|
||||
size="T300"
|
||||
/>
|
||||
</Box>
|
||||
<Box direction="Column" gap="200">
|
||||
<Button
|
||||
type="submit"
|
||||
variant="Critical"
|
||||
onClick={() => leaveSpace()}
|
||||
before={leaving ? <Spinner fill="Solid" variant="Critical" size="200" /> : undefined}
|
||||
loading={leaving}
|
||||
spinnerVariant="Critical"
|
||||
spinnerSize="200"
|
||||
aria-disabled={isBusy || leaveState.status === AsyncStatus.Success}
|
||||
>
|
||||
<Text size="B400">{leaving ? 'Leaving...' : 'Leave Space Only'}</Text>
|
||||
@@ -111,9 +111,9 @@ export function LeaveSpacePrompt({ roomId, onDone, onCancel }: LeaveSpacePromptP
|
||||
variant="Critical"
|
||||
fill="Soft"
|
||||
onClick={() => leaveAll()}
|
||||
before={
|
||||
leavingAll ? <Spinner fill="Solid" variant="Critical" size="200" /> : undefined
|
||||
}
|
||||
loading={leavingAll}
|
||||
spinnerVariant="Critical"
|
||||
spinnerSize="200"
|
||||
aria-disabled={isBusy || leaveAllState.status === AsyncStatus.Success}
|
||||
>
|
||||
<Text size="B400">
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { ReactNode } from 'react';
|
||||
import { as, Avatar, Box, Text } from 'folds';
|
||||
import { userFallbackIcon } from '$components/icons/phosphor';
|
||||
import type { MatrixClient, Room, RoomMember } from '$types/matrix-sdk';
|
||||
import { getAvatarUrl, getMemberDisplayName } from '$utils/room';
|
||||
import { getAvatarUrl, getMemberDisplayName } from '$utils/room/display';
|
||||
import { getMxIdLocalPart } from '$utils/matrix';
|
||||
import { useSableCosmetics } from '$hooks/useSableCosmetics';
|
||||
import { useAtomValue } from 'jotai';
|
||||
|
||||
@@ -55,7 +55,8 @@ import { nicknamesAtom } from '$state/nicknames';
|
||||
import { settingsAtom } from '$state/settings';
|
||||
import { useSetting } from '$state/hooks/settings';
|
||||
import type { GetContentCallback } from '$types/matrix/room';
|
||||
import { getEditedEvent, getMemberAvatarMxc, getMemberDisplayName } from '$utils/room';
|
||||
import { getMemberAvatarMxc, getMemberDisplayName } from '$utils/room/display';
|
||||
import { getEditedEvent } from '$utils/room/relations';
|
||||
import { getMxIdLocalPart, mxcUrlToHttp } from '$utils/matrix';
|
||||
import * as customHtmlCss from '$styles/CustomHtml.css';
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ export function FileDownloadButton({ filename, url, mimeType, encInfo }: FileDow
|
||||
);
|
||||
}
|
||||
|
||||
export type FileHeaderProps = {
|
||||
type FileHeaderProps = {
|
||||
body: string;
|
||||
mimeType: string;
|
||||
after?: ReactNode;
|
||||
|
||||
@@ -3,7 +3,7 @@ import { ArrowSquareOut, sizedIcon, Link } from '$components/icons/phosphor';
|
||||
import { Box, Chip, Text, toRem } from 'folds';
|
||||
import { type IContent, type IPreviewUrlResponse, type MatrixClient } from '$types/matrix-sdk';
|
||||
import { isJumboEmojiText } from '$utils/emojiDetection';
|
||||
import { trimReplyFromBody } from '$utils/room';
|
||||
import { trimReplyFromBody } from '$utils/room/display';
|
||||
import type {
|
||||
IAudioContent,
|
||||
IAudioInfo,
|
||||
|
||||
@@ -15,6 +15,7 @@ import * as css from './PollEvent.css';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { PollResponsesViewer } from '$features/room/poll-modals';
|
||||
import { ModalOverlay } from '$components/modal-overlay/ModalOverlay';
|
||||
import { useMatrixEvent } from '$hooks/useMatrixEvent';
|
||||
|
||||
type PollEventProps = {
|
||||
content: Record<string, unknown>;
|
||||
@@ -100,8 +101,8 @@ export function PollEvent({ content, mEvent, mx, room }: PollEventProps) {
|
||||
const [isEnded, setIsEnded] = useState(getEndIndex(sortedChildEvents) !== -1);
|
||||
const [updateCounter, setUpdateCounter] = useState(0);
|
||||
|
||||
useEffect(() => {
|
||||
const handleUpdate = (event: MatrixEvent) => {
|
||||
const handleUpdate = useCallback(
|
||||
(event: MatrixEvent) => {
|
||||
const relation = event.getRelation();
|
||||
if (
|
||||
relation?.event_id === eventId ||
|
||||
@@ -110,12 +111,11 @@ export function PollEvent({ content, mEvent, mx, room }: PollEventProps) {
|
||||
) {
|
||||
setUpdateCounter((c) => c + 1);
|
||||
}
|
||||
};
|
||||
room.on(RoomEvent.Timeline, handleUpdate);
|
||||
return () => {
|
||||
room.off(RoomEvent.Timeline, handleUpdate);
|
||||
};
|
||||
}, [room, eventId]);
|
||||
},
|
||||
[eventId]
|
||||
);
|
||||
|
||||
useMatrixEvent(room, RoomEvent.Timeline, handleUpdate);
|
||||
|
||||
// ensure a new sorted array is only generated when a new list is made
|
||||
useEffect(() => {
|
||||
|
||||
@@ -4,7 +4,7 @@ import { sizedIcon, Warning } from '$components/icons/phosphor';
|
||||
import classNames from 'classnames';
|
||||
import type { MatrixClient, MatrixEvent, Room } from '$types/matrix-sdk';
|
||||
import { getHexcodeForEmoji, getShortcodeFor } from '$plugins/emoji';
|
||||
import { getMemberDisplayName } from '$utils/room';
|
||||
import { getMemberDisplayName } from '$utils/room/display';
|
||||
import { eventWithShortcode, getMxIdLocalPart, mxcUrlToHttp } from '$utils/matrix';
|
||||
import { useAtomValue } from 'jotai';
|
||||
import { nicknamesAtom } from '$state/nicknames';
|
||||
|
||||
@@ -75,7 +75,7 @@ vi.mock('$features/settings/useSettingsLinkBaseUrl', () => ({
|
||||
useSettingsLinkBaseUrl: () => 'https://app.sable.moe',
|
||||
}));
|
||||
|
||||
vi.mock('$utils/room', async (importActual) => {
|
||||
vi.mock('$utils/room/display', async (importActual) => {
|
||||
const actual = (await importActual()) as object;
|
||||
return {
|
||||
...actual,
|
||||
|
||||
@@ -25,12 +25,10 @@ import {
|
||||
} from '$components/icons/phosphor';
|
||||
import {
|
||||
getMemberDisplayName,
|
||||
getReactionKey,
|
||||
getReactionShortcode,
|
||||
getRedactionTargetId,
|
||||
trimReplyFromBody,
|
||||
trimReplyFromFormattedBody,
|
||||
} from '$utils/room';
|
||||
} from '$utils/room/display';
|
||||
import { getReactionKey, getReactionShortcode, getRedactionTargetId } from '$utils/room/relations';
|
||||
import { getMxIdLocalPart } from '$utils/matrix';
|
||||
import { randomNumberBetween } from '$utils/common';
|
||||
import { sanitizeCustomHtml } from '$utils/sanitize';
|
||||
|
||||
@@ -3,7 +3,7 @@ import type { Room, MatrixEvent } from '$types/matrix-sdk';
|
||||
import { useSetAtom } from 'jotai';
|
||||
import { MenuItem, Text } from 'folds';
|
||||
import { Clock, menuIcon } from '$components/icons/phosphor';
|
||||
import { getEventEdits } from '$utils/room';
|
||||
import { getEventEdits } from '$utils/room/relations';
|
||||
import { modalAtom, ModalType } from '$state/modal';
|
||||
import * as css from '$features/room/message/styles.css';
|
||||
import { EventHistory } from '$components/event-history';
|
||||
|
||||
@@ -4,18 +4,17 @@ import { useMatrixClient } from '$hooks/useMatrixClient';
|
||||
import { modalAtom, ModalType } from '$state/modal';
|
||||
import { MenuItem, Text, as } from 'folds';
|
||||
import { ArrowRight, menuIcon } from '$components/icons/phosphor';
|
||||
import { useAtomValue, useSetAtom } from 'jotai';
|
||||
import { useSetAtom } from 'jotai';
|
||||
import type { MatrixEvent, Room } from '$types/matrix-sdk';
|
||||
import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import { allRoomsAtom } from '$state/room-list/roomList';
|
||||
import { useAllJoinedRoomsSet, useGetRoom } from '$hooks/useGetRoom';
|
||||
import { factoryRoomIdByActivity } from '$utils/sort';
|
||||
import { useMessageTargetRooms } from '$hooks/useMessageTargetRooms';
|
||||
import * as css from '$features/room/message/styles.css';
|
||||
import { sanitizeCustomHtml, sanitizeText } from '$utils/sanitize';
|
||||
import { createDebugLogger } from '$utils/debugLogger';
|
||||
import * as Sentry from '@sentry/react';
|
||||
import { isRoomPrivate } from '$utils/roomVisibility';
|
||||
import { canForwardEvent } from '$utils/room';
|
||||
import { canForwardEvent } from '$utils/room/relations';
|
||||
import * as prefix from '$unstable/prefixes';
|
||||
import { SearchWrapper } from '$features/navigate';
|
||||
import { useDismissOnBack } from '$utils/androidBack';
|
||||
@@ -100,7 +99,6 @@ export function MessageForwardInternal({
|
||||
const forwardable = canForwardEvent(mEvent);
|
||||
const [isForwarding, setIsForwarding] = useState(false);
|
||||
const [forwardError, setForwardError] = useState<string | null>(null);
|
||||
const allRooms = useAtomValue(allRoomsAtom);
|
||||
const allJoinedRooms = useAllJoinedRoomsSet();
|
||||
const getRoom = useGetRoom(allJoinedRooms);
|
||||
|
||||
@@ -112,16 +110,7 @@ export function MessageForwardInternal({
|
||||
useDismissOnBack(onClose);
|
||||
|
||||
// possible targets to forward the message to
|
||||
const forwardTargets = useMemo(
|
||||
() =>
|
||||
allRooms
|
||||
.filter((id) => {
|
||||
const target = getRoom(id);
|
||||
return !!target && !target.isSpaceRoom() && target.maySendMessage();
|
||||
})
|
||||
.sort(factoryRoomIdByActivity(mx)),
|
||||
[allRooms, getRoom, mx]
|
||||
);
|
||||
const forwardTargets = useMessageTargetRooms();
|
||||
|
||||
const forwardToRoom = useCallback(
|
||||
(targetRoomId: string) => {
|
||||
|
||||
@@ -4,7 +4,7 @@ import { useSetAtom } from 'jotai';
|
||||
import { MenuItem, Text } from 'folds';
|
||||
import { CodeBlock, menuIcon } from '$components/icons/phosphor';
|
||||
import { TextViewer } from '$components/text-viewer';
|
||||
import { getEventEdits } from '$utils/room';
|
||||
import { getEventEdits } from '$utils/room/relations';
|
||||
import { modalAtom, ModalType } from '$state/modal';
|
||||
import * as css from '$features/room/message/styles.css';
|
||||
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
import type { RoomPinnedEventsEventContent, StateEvents } from '$types/matrix-sdk';
|
||||
import { type Room, type MatrixEvent, type Relations, EventType } from '$types/matrix-sdk';
|
||||
import { canEditEvent, canForwardEvent, getEventEdits, isThreadRelationEvent } from '$utils/room';
|
||||
import {
|
||||
canEditEvent,
|
||||
canForwardEvent,
|
||||
getEventEdits,
|
||||
isThreadRelationEvent,
|
||||
} from '$utils/room/relations';
|
||||
import { MessageReportItem } from './MessageReport';
|
||||
import type { RectCords } from 'folds';
|
||||
import { as, Box, config, IconButton, Line, Menu, MenuItem, PopOut, Text } from 'folds';
|
||||
@@ -323,7 +328,7 @@ const MessageFavoriteGifItem = as<
|
||||
);
|
||||
});
|
||||
|
||||
export type OptionEmojiMenuProps = {
|
||||
type OptionEmojiMenuProps = {
|
||||
mEvent: MatrixEvent;
|
||||
closeMenu: () => void;
|
||||
onReactionToggle?: (targetEventId: string, key: string, shortcode?: string) => void;
|
||||
|
||||
@@ -0,0 +1,225 @@
|
||||
// oxlint-disable typescript/no-explicit-any
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest';
|
||||
import { cleanup, render, screen } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { ScreenSize, ScreenSizeProvider } from '$hooks/useScreenSize';
|
||||
|
||||
// ── Mocks ───────────────────────────────────────────────────────────────────
|
||||
|
||||
/**
|
||||
* Mock FocusTrap that simulates Escape behavior. When escapeDeactivates is
|
||||
* truthy, pressing Escape calls onDeactivate. This lets us test the
|
||||
* escapeDeactivates prop without dealing with jsdom's incompatible tabbable
|
||||
* library (which doesn't find tabbable elements at all in jsdom v29).
|
||||
*/
|
||||
vi.mock('focus-trap-react', () => {
|
||||
const React = require('react');
|
||||
const FocusTrapComponent = ({ children, focusTrapOptions }: any) => {
|
||||
const opts = focusTrapOptions ?? {};
|
||||
const { escapeDeactivates, onDeactivate } = opts;
|
||||
|
||||
React.useEffect(() => {
|
||||
const handleKeyDown = (e: any) => {
|
||||
if (e.key === 'Escape') {
|
||||
const esc = escapeDeactivates;
|
||||
const deactivate = typeof esc === 'function' ? esc(e) : esc === true || esc === undefined;
|
||||
if (deactivate) {
|
||||
onDeactivate?.();
|
||||
e.stopPropagation();
|
||||
}
|
||||
}
|
||||
};
|
||||
document.addEventListener('keydown', handleKeyDown);
|
||||
return () => {
|
||||
document.removeEventListener('keydown', handleKeyDown);
|
||||
};
|
||||
}, [escapeDeactivates, onDeactivate]);
|
||||
|
||||
return React.createElement('div', { 'data-testid': 'focus-trap' }, children);
|
||||
};
|
||||
|
||||
return { default: FocusTrapComponent, FocusTrap: FocusTrapComponent };
|
||||
});
|
||||
|
||||
vi.mock('folds', () => ({
|
||||
Box: ({ children, direction }: any) => (
|
||||
<div data-testid="box" data-direction={direction}>
|
||||
{children}
|
||||
</div>
|
||||
),
|
||||
Overlay: ({ open, backdrop, children }: any) => (
|
||||
<div data-testid="overlay" data-open={String(!!open)}>
|
||||
<div data-testid="overlay-backdrop">{backdrop}</div>
|
||||
{children}
|
||||
</div>
|
||||
),
|
||||
OverlayBackdrop: () => <div data-testid="overlay-backdrop-inner">backdrop</div>,
|
||||
OverlayCenter: ({ children }: any) => <div data-testid="overlay-center">{children}</div>,
|
||||
}));
|
||||
|
||||
vi.mock('$components/MobileSwipeDownModal', () => ({
|
||||
MobileSwipeDownModal: ({ children }: any) => (
|
||||
<div data-testid="mobile-swipe-down">
|
||||
{children(<div data-testid="drag-handle">drag-handle</div>, {
|
||||
onTouchStart: vi.fn<() => void>(),
|
||||
onTouchMove: vi.fn<() => void>(),
|
||||
onTouchEnd: vi.fn<() => void>(),
|
||||
})}
|
||||
</div>
|
||||
),
|
||||
}));
|
||||
|
||||
vi.mock('$utils/androidBack', () => ({
|
||||
useDismissOnBack: vi.fn<() => void>(),
|
||||
}));
|
||||
|
||||
vi.mock('$utils/keyboard', () => ({
|
||||
stopPropagation: () => false,
|
||||
}));
|
||||
|
||||
vi.mock('$features/room/message/styles.css', () => ({
|
||||
MessageOptionsMenu: 'mock-message-options-menu',
|
||||
MessageMobileDragHandle: 'mock-mobile-drag-handle',
|
||||
MessageMobileDragIndicator: 'mock-mobile-drag-indicator',
|
||||
MessageMobileOptionsWrapped: 'mock-mobile-options-wrapped',
|
||||
MessageMobileOptionsContainer: 'mock-mobile-options-container',
|
||||
}));
|
||||
|
||||
import { ModalOverlay } from './ModalOverlay';
|
||||
|
||||
afterEach(() => {
|
||||
cleanup();
|
||||
});
|
||||
|
||||
// ── Render helpers ──────────────────────────────────────────────────────────
|
||||
|
||||
function desktop(props: Partial<Parameters<typeof ModalOverlay>[0]> = {}) {
|
||||
return render(
|
||||
<ScreenSizeProvider value={ScreenSize.Desktop}>
|
||||
<ModalOverlay requestClose={vi.fn<() => void>()} {...props}>
|
||||
<div data-testid="modal-child">Modal Content</div>
|
||||
</ModalOverlay>
|
||||
</ScreenSizeProvider>
|
||||
);
|
||||
}
|
||||
|
||||
function mobile(props: Partial<Parameters<typeof ModalOverlay>[0]> = {}) {
|
||||
return render(
|
||||
<ScreenSizeProvider value={ScreenSize.Mobile}>
|
||||
<ModalOverlay requestClose={vi.fn<() => void>()} {...props}>
|
||||
<div data-testid="modal-child">Modal Content</div>
|
||||
</ModalOverlay>
|
||||
</ScreenSizeProvider>
|
||||
);
|
||||
}
|
||||
|
||||
// ── Tests ───────────────────────────────────────────────────────────────────
|
||||
|
||||
describe('ModalOverlay', () => {
|
||||
describe('escapeDeactivates', () => {
|
||||
it('calls requestClose on Escape when escapeDeactivates is true', async () => {
|
||||
const requestClose = vi.fn<() => void>();
|
||||
const user = userEvent.setup();
|
||||
|
||||
render(
|
||||
<ScreenSizeProvider value={ScreenSize.Desktop}>
|
||||
<ModalOverlay requestClose={requestClose} escapeDeactivates={true}>
|
||||
<div data-testid="child">Content</div>
|
||||
</ModalOverlay>
|
||||
</ScreenSizeProvider>
|
||||
);
|
||||
|
||||
await user.keyboard('{Escape}');
|
||||
expect(requestClose).toHaveBeenCalledOnce();
|
||||
});
|
||||
|
||||
it('does NOT call requestClose on Escape when escapeDeactivates is false', async () => {
|
||||
const requestClose = vi.fn<() => void>();
|
||||
const user = userEvent.setup();
|
||||
|
||||
render(
|
||||
<ScreenSizeProvider value={ScreenSize.Desktop}>
|
||||
<ModalOverlay requestClose={requestClose} escapeDeactivates={false}>
|
||||
<div data-testid="child">Content</div>
|
||||
</ModalOverlay>
|
||||
</ScreenSizeProvider>
|
||||
);
|
||||
|
||||
await user.keyboard('{Escape}');
|
||||
expect(requestClose).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('does NOT call requestClose with default escapeDeactivates (stopPropagation)', async () => {
|
||||
// stopPropagation returns false, so Escape should NOT trigger close
|
||||
const requestClose = vi.fn<() => void>();
|
||||
const user = userEvent.setup();
|
||||
|
||||
render(
|
||||
<ScreenSizeProvider value={ScreenSize.Desktop}>
|
||||
<ModalOverlay requestClose={requestClose}>
|
||||
<div data-testid="child">Content</div>
|
||||
</ModalOverlay>
|
||||
</ScreenSizeProvider>
|
||||
);
|
||||
|
||||
await user.keyboard('{Escape}');
|
||||
expect(requestClose).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('presentation', () => {
|
||||
it('renders centred overlay on desktop (default)', () => {
|
||||
desktop();
|
||||
|
||||
expect(screen.getByTestId('overlay')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('overlay-center')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('overlay-backdrop-inner')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('modal-child')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('focus-trap')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders overlay with open=false on desktop', () => {
|
||||
desktop({ open: false });
|
||||
|
||||
expect(screen.getByTestId('overlay')).toHaveAttribute('data-open', 'false');
|
||||
});
|
||||
|
||||
it('renders centred overlay on mobile when mobile="centred"', () => {
|
||||
mobile({ mobile: 'centred' });
|
||||
|
||||
expect(screen.getByTestId('overlay')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('overlay-center')).toBeInTheDocument();
|
||||
expect(screen.queryByTestId('mobile-swipe-down')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders fullscreen overlay on mobile when mobile="fullscreen"', () => {
|
||||
mobile({ mobile: 'fullscreen' });
|
||||
|
||||
expect(screen.getByTestId('overlay')).toBeInTheDocument();
|
||||
// Fullscreen does NOT render OverlayCenter or backdrop
|
||||
expect(screen.queryByTestId('overlay-center')).not.toBeInTheDocument();
|
||||
expect(screen.queryByTestId('overlay-backdrop-inner')).not.toBeInTheDocument();
|
||||
expect(screen.queryByTestId('mobile-swipe-down')).not.toBeInTheDocument();
|
||||
// Focus-trap wraps the fullscreen content
|
||||
expect(screen.getByTestId('focus-trap')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('modal-child')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders sheet via MobileSwipeDownModal on mobile when mobile="sheet"', () => {
|
||||
mobile({ mobile: 'sheet' });
|
||||
|
||||
expect(screen.getByTestId('mobile-swipe-down')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('drag-handle')).toBeInTheDocument();
|
||||
expect(screen.queryByTestId('overlay')).not.toBeInTheDocument();
|
||||
expect(screen.queryByTestId('overlay-center')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('defaults to centred on mobile', () => {
|
||||
mobile();
|
||||
|
||||
expect(screen.getByTestId('overlay')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('overlay-center')).toBeInTheDocument();
|
||||
expect(screen.queryByTestId('mobile-swipe-down')).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,9 +1,11 @@
|
||||
import type { ComponentProps, MutableRefObject, ReactNode } from 'react';
|
||||
import FocusTrap from 'focus-trap-react';
|
||||
import { Overlay, OverlayBackdrop, OverlayCenter } from 'folds';
|
||||
import { Box, Overlay, OverlayBackdrop, OverlayCenter } from 'folds';
|
||||
import { ScreenSize, useScreenSizeOptionally } from '$hooks/useScreenSize';
|
||||
import { stopPropagation } from '$utils/keyboard';
|
||||
import { useDismissOnBack } from '$utils/androidBack';
|
||||
import { MobileSwipeDownModal } from '$components/MobileSwipeDownModal';
|
||||
import * as messageCss from '$features/room/message/styles.css';
|
||||
|
||||
type FocusTrapOptions = ComponentProps<typeof FocusTrap>['focusTrapOptions'];
|
||||
|
||||
@@ -12,8 +14,10 @@ type ModalOverlayProps = {
|
||||
requestClose: () => void;
|
||||
/** Set false for overlays that must be dismissed deliberately, not by a stray click. */
|
||||
dismissOnClickOutside?: boolean;
|
||||
/** `fullscreen` drops the centred modal on phones and fills the viewport instead. */
|
||||
mobile?: 'centred' | 'fullscreen';
|
||||
/** `centred` keeps the desktop-style dialog on phones.
|
||||
* `fullscreen` drops the centred modal and fills the viewport.
|
||||
* `sheet` rises as a bottom sheet with a swipe-down-to-dismiss handle. */
|
||||
mobile?: 'centred' | 'fullscreen' | 'sheet';
|
||||
/** The modal element, used as the focus fallback and as the fullscreen wrapper. */
|
||||
contentRef?: MutableRefObject<HTMLDivElement | null>;
|
||||
/** Set false for flows that Escape must not abort, such as device verification. */
|
||||
@@ -58,6 +62,30 @@ export function ModalOverlay({
|
||||
);
|
||||
}
|
||||
|
||||
if (open && isMobile && mobile === 'sheet') {
|
||||
const focusTrapOptions = {
|
||||
initialFocus: false,
|
||||
fallbackFocus: () => document.body,
|
||||
onDeactivate: requestClose,
|
||||
clickOutsideDeactivates: dismissOnClickOutside,
|
||||
escapeDeactivates,
|
||||
};
|
||||
return (
|
||||
<MobileSwipeDownModal requestClose={requestClose}>
|
||||
{(dragHandle) => (
|
||||
<FocusTrap focusTrapOptions={focusTrapOptions}>
|
||||
<div role="dialog" aria-modal="true" className={messageCss.MessageOptionsMenu}>
|
||||
<Box direction="Column">
|
||||
{dragHandle}
|
||||
{children}
|
||||
</Box>
|
||||
</div>
|
||||
</FocusTrap>
|
||||
)}
|
||||
</MobileSwipeDownModal>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Overlay open={open} backdrop={<OverlayBackdrop />}>
|
||||
<OverlayCenter>
|
||||
|
||||
@@ -3,7 +3,7 @@ import classNames from 'classnames';
|
||||
import { Header, as } from 'folds';
|
||||
import * as css from './styles.css';
|
||||
|
||||
export type NavCategoryHeaderProps = {
|
||||
type NavCategoryHeaderProps = {
|
||||
children: ReactNode;
|
||||
};
|
||||
export const NavCategoryHeader = as<'div', NavCategoryHeaderProps>(
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
import type { ReactNode } from 'react';
|
||||
import { forwardRef } from 'react';
|
||||
import { Box, Menu, MenuItem, Text, config, toRem } from 'folds';
|
||||
import { useMatrixClient } from '$hooks/useMatrixClient';
|
||||
import { useSetting } from '$state/hooks/settings';
|
||||
import { settingsAtom } from '$state/settings';
|
||||
import { roomToUnreadAtom } from '$state/room/roomToUnread';
|
||||
import { useRoomsUnread } from '$state/hooks/unread';
|
||||
import { markAsRead } from '$utils/notifications';
|
||||
import { Checks, menuIcon } from '$components/icons/phosphor';
|
||||
|
||||
type NavMenuProps = {
|
||||
rooms: string[];
|
||||
requestClose: () => void;
|
||||
children?: ReactNode;
|
||||
};
|
||||
|
||||
export const NavMenu = forwardRef<HTMLDivElement, NavMenuProps>(
|
||||
({ rooms, requestClose, children }, ref) => {
|
||||
const mx = useMatrixClient();
|
||||
const [hideReads] = useSetting(settingsAtom, 'hideReads');
|
||||
const unread = useRoomsUnread(rooms, roomToUnreadAtom);
|
||||
|
||||
const handleMarkAsRead = () => {
|
||||
if (!unread) return;
|
||||
rooms.forEach((rId) => markAsRead(mx, rId, hideReads));
|
||||
requestClose();
|
||||
};
|
||||
|
||||
return (
|
||||
<Menu ref={ref} style={{ maxWidth: toRem(160), width: '100vw' }}>
|
||||
<Box direction="Column" gap="100" style={{ padding: config.space.S100 }}>
|
||||
<MenuItem
|
||||
onClick={handleMarkAsRead}
|
||||
size="300"
|
||||
after={menuIcon(Checks)}
|
||||
radii="300"
|
||||
aria-disabled={!unread}
|
||||
>
|
||||
<Text style={{ flexGrow: 1 }} as="span" size="T300" truncate>
|
||||
Mark as Read
|
||||
</Text>
|
||||
</MenuItem>
|
||||
{children}
|
||||
</Box>
|
||||
</Menu>
|
||||
);
|
||||
}
|
||||
);
|
||||
NavMenu.displayName = 'NavMenu';
|
||||
@@ -0,0 +1,69 @@
|
||||
import type { ReactNode } from 'react';
|
||||
import type { RectCords } from 'folds';
|
||||
import { Box, IconButton, Text } from 'folds';
|
||||
import { composerIcon, DotsThreeOutlineVerticalIcon } from '$components/icons/phosphor';
|
||||
import { PageNavHeader } from '$components/page';
|
||||
import { ResponsiveMenu } from '$components/ResponsiveMenu';
|
||||
|
||||
type PageNavHeaderWithMenuProps = {
|
||||
hideText?: boolean;
|
||||
title: string;
|
||||
collapsedIcon: ReactNode;
|
||||
menu: ReactNode;
|
||||
anchor: RectCords | undefined;
|
||||
requestClose: () => void;
|
||||
triggerProps: {
|
||||
onClick: React.MouseEventHandler<HTMLButtonElement>;
|
||||
};
|
||||
};
|
||||
|
||||
export function PageNavHeaderWithMenu({
|
||||
hideText,
|
||||
title,
|
||||
collapsedIcon,
|
||||
menu,
|
||||
anchor,
|
||||
requestClose,
|
||||
triggerProps,
|
||||
}: PageNavHeaderWithMenuProps) {
|
||||
return (
|
||||
<>
|
||||
<PageNavHeader size="600">
|
||||
{hideText ? (
|
||||
<Box alignItems="Center" grow="Yes" justifyContent="Center">
|
||||
<IconButton aria-pressed={!!anchor} variant="Background" onClick={triggerProps.onClick}>
|
||||
{collapsedIcon}
|
||||
</IconButton>
|
||||
</Box>
|
||||
) : (
|
||||
<Box grow="Yes" gap="300">
|
||||
<Box grow="Yes" alignItems="Center">
|
||||
<Text size="H4" truncate>
|
||||
{title}
|
||||
</Text>
|
||||
</Box>
|
||||
<Box shrink="No">
|
||||
<IconButton
|
||||
aria-pressed={!!anchor}
|
||||
variant="Background"
|
||||
onClick={triggerProps.onClick}
|
||||
>
|
||||
{composerIcon(DotsThreeOutlineVerticalIcon, {
|
||||
weight: anchor ? 'fill' : 'regular',
|
||||
})}
|
||||
</IconButton>
|
||||
</Box>
|
||||
</Box>
|
||||
)}
|
||||
</PageNavHeader>
|
||||
<ResponsiveMenu
|
||||
anchor={anchor}
|
||||
requestClose={requestClose}
|
||||
position="Bottom"
|
||||
align="End"
|
||||
offset={6}
|
||||
menu={menu}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
import type { Dispatch, ReactNode, SetStateAction } from 'react';
|
||||
import { Box, toRem } from 'folds';
|
||||
import { PageNav } from '$components/page';
|
||||
import { SidebarResizer } from '$pages/client/sidebar/SidebarResizer';
|
||||
import { UserQuickTools } from '$pages/client/sidebar/UserQuickTools';
|
||||
|
||||
type PageNavShellProps = {
|
||||
header: ReactNode;
|
||||
children: ReactNode;
|
||||
curWidth: number;
|
||||
setCurWidth: Dispatch<SetStateAction<number>>;
|
||||
roomSidebarWidth: number;
|
||||
setRoomSidebarWidth: (width: number) => void;
|
||||
setIsResizingSidebar: (is: boolean) => void;
|
||||
isMobile: boolean;
|
||||
oldSidebar: boolean;
|
||||
};
|
||||
|
||||
export function PageNavShell({
|
||||
header,
|
||||
children,
|
||||
curWidth,
|
||||
setCurWidth,
|
||||
roomSidebarWidth,
|
||||
setRoomSidebarWidth,
|
||||
setIsResizingSidebar,
|
||||
isMobile,
|
||||
oldSidebar,
|
||||
}: PageNavShellProps) {
|
||||
return (
|
||||
<Box
|
||||
shrink="No"
|
||||
style={{
|
||||
position: 'relative',
|
||||
width: isMobile ? '100%' : toRem(curWidth),
|
||||
}}
|
||||
>
|
||||
<PageNav>
|
||||
{header}
|
||||
{children}
|
||||
</PageNav>
|
||||
{!isMobile && (
|
||||
<SidebarResizer
|
||||
setCurWidth={setCurWidth}
|
||||
sidebarWidth={roomSidebarWidth}
|
||||
setSidebarWidth={setRoomSidebarWidth}
|
||||
instep={50}
|
||||
outstep={190}
|
||||
minValue={50}
|
||||
maxValue={500}
|
||||
setAnnouncement={setIsResizingSidebar}
|
||||
/>
|
||||
)}
|
||||
{!oldSidebar && !isMobile && <UserQuickTools width={curWidth + 66} compact={false} />}
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import { resolveSection, type SectionNav } from '$pages/pathUtils';
|
||||
import { HOME_ROOM_PATH, DIRECT_ROOM_PATH, SPACE_ROOM_PATH } from '$pages/paths';
|
||||
import { isRoomAlias, isRoomId } from '$utils/matrix';
|
||||
|
||||
export type DisplayedRoom = {
|
||||
type DisplayedRoom = {
|
||||
roomIdOrAlias: string;
|
||||
eventId?: string;
|
||||
};
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useSetAtom } from 'jotai';
|
||||
import { Box, Text, color, config, toRem } from 'folds';
|
||||
import { SquaresFour, sizedIcon } from '$components/icons/phosphor';
|
||||
import { useSetting } from '$state/hooks/settings';
|
||||
import { settingsAtom } from '$state/settings';
|
||||
import { isResizingSidebarAtom } from '$state/isResizingSidebar';
|
||||
import { useSidebarWidth } from '$hooks/useSidebarWidth';
|
||||
import { SidebarResizer } from '$pages/client/sidebar/SidebarResizer';
|
||||
import { UserQuickTools } from '$pages/client/sidebar/UserQuickTools';
|
||||
import { PageNav, PageNavHeader } from './Page';
|
||||
@@ -14,14 +10,15 @@ import { PageNav, PageNavHeader } from './Page';
|
||||
* an icon once dragged narrow enough for the title to stop fitting.
|
||||
*/
|
||||
export function SidebarPanel({ title }: { title: string }) {
|
||||
const setIsResizingSidebar = useSetAtom(isResizingSidebarAtom);
|
||||
const [roomSidebarWidth, setRoomSidebarWidth] = useSetting(settingsAtom, 'roomSidebarWidth');
|
||||
const [oldSidebar] = useSetting(settingsAtom, 'oldSidebar');
|
||||
const [curWidth, setCurWidth] = useState(roomSidebarWidth);
|
||||
|
||||
useEffect(() => {
|
||||
setCurWidth(roomSidebarWidth);
|
||||
}, [roomSidebarWidth]);
|
||||
const {
|
||||
curWidth,
|
||||
setCurWidth,
|
||||
roomSidebarWidth,
|
||||
setRoomSidebarWidth,
|
||||
setIsResizingSidebar,
|
||||
hideText,
|
||||
oldSidebar,
|
||||
} = useSidebarWidth();
|
||||
|
||||
return (
|
||||
<Box
|
||||
@@ -37,7 +34,7 @@ export function SidebarPanel({ title }: { title: string }) {
|
||||
<PageNav>
|
||||
<PageNavHeader size="600">
|
||||
<Box grow="Yes" gap="300" justifyContent="Center">
|
||||
{curWidth <= 80 ? (
|
||||
{hideText ? (
|
||||
sizedIcon(SquaresFour, '200', { filled: true })
|
||||
) : (
|
||||
<Box grow="Yes">
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
export * from './Page';
|
||||
export * from './MessageSearchHeader';
|
||||
export * from './SettingsSectionPage';
|
||||
export * from './PageNavHeaderWithMenu';
|
||||
@@ -13,7 +13,8 @@ import { onEnterOrSpace } from '$utils/keyboard';
|
||||
|
||||
import { useJoinedRoomId } from '$hooks/useJoinedRoomId';
|
||||
import { useElementSizeObserver } from '$hooks/useElementSizeObserver';
|
||||
import { getRoomAvatarUrl, getStateEvent } from '$utils/room';
|
||||
import { getRoomAvatarUrl } from '$utils/room/display';
|
||||
import { getStateEvent } from '$utils/room/hierarchy';
|
||||
import { useStateEventCallback } from '$hooks/useStateEventCallback';
|
||||
import { useMediaAuthentication } from '$hooks/useMediaAuthentication';
|
||||
import { KnockRoomPrompt } from '$components/knock-room-prompt';
|
||||
|
||||
@@ -4,7 +4,8 @@ import type { Room } from '$types/matrix-sdk';
|
||||
import { useAtomValue } from 'jotai';
|
||||
import type { IRoomCreateContent } from '$types/matrix/room';
|
||||
|
||||
import { getMemberDisplayName, getStateEvent } from '$utils/room';
|
||||
import { getMemberDisplayName } from '$utils/room/display';
|
||||
import { getStateEvent } from '$utils/room/hierarchy';
|
||||
import { nicknamesAtom } from '$state/nicknames';
|
||||
import { useMatrixClient } from '$hooks/useMatrixClient';
|
||||
import { getMxIdLocalPart, mxcUrlToHttp, removeRoomIdFromMDirect } from '$utils/matrix';
|
||||
@@ -24,7 +25,7 @@ import { userFallbackIcon } from '$components/icons/phosphor';
|
||||
import { DirectInvitePrompt } from '$components/direct-invite-prompt';
|
||||
import { EventType, KnownMembership } from '$types/matrix-sdk';
|
||||
|
||||
export type RoomIntroProps = {
|
||||
type RoomIntroProps = {
|
||||
room: Room;
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
import type { ReactNode } from 'react';
|
||||
import { Switch } from 'folds';
|
||||
import { SequenceCard, SequenceCardStyle } from '$components/sequence-card';
|
||||
import { SettingTile } from './SettingTile';
|
||||
|
||||
type SettingToggleProps = {
|
||||
title: string;
|
||||
focusId: string;
|
||||
description?: ReactNode;
|
||||
value: boolean;
|
||||
onChange: (value: boolean) => void;
|
||||
disabled?: boolean;
|
||||
switchVariant?: 'Primary' | 'Secondary';
|
||||
ariaLabel?: string;
|
||||
switchTitle?: string;
|
||||
};
|
||||
|
||||
export function SettingToggle({
|
||||
title,
|
||||
focusId,
|
||||
description,
|
||||
value,
|
||||
onChange,
|
||||
disabled,
|
||||
switchVariant,
|
||||
ariaLabel,
|
||||
switchTitle,
|
||||
}: SettingToggleProps) {
|
||||
return (
|
||||
<SequenceCard className={SequenceCardStyle} variant="SurfaceVariant" direction="Column">
|
||||
<SettingTile
|
||||
title={title}
|
||||
focusId={focusId}
|
||||
description={description}
|
||||
after={
|
||||
<Switch
|
||||
variant={switchVariant ?? 'Primary'}
|
||||
value={value}
|
||||
onChange={onChange}
|
||||
disabled={disabled}
|
||||
aria-label={ariaLabel ?? focusId}
|
||||
title={switchTitle}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
</SequenceCard>
|
||||
);
|
||||
}
|
||||
@@ -1 +1,2 @@
|
||||
export * from './SettingTile';
|
||||
export * from './SettingToggle';
|
||||
@@ -0,0 +1,68 @@
|
||||
import type { ReactNode } from 'react';
|
||||
import {
|
||||
SidebarAvatar,
|
||||
SidebarItemLeft,
|
||||
SidebarUnreadBadge,
|
||||
SidebarItemTooltip,
|
||||
} from '$components/sidebar';
|
||||
import { ResponsiveMenu } from '$components/ResponsiveMenu';
|
||||
import type { MenuAnchor } from '$hooks/useMenuAnchor';
|
||||
|
||||
type SidebarTabProps = {
|
||||
icon: ReactNode;
|
||||
selected: boolean;
|
||||
tooltip: string;
|
||||
onClick: () => void;
|
||||
menu: ReactNode;
|
||||
menuAnchor: MenuAnchor<HTMLButtonElement>;
|
||||
unreadHighlight?: boolean;
|
||||
unreadCount?: number;
|
||||
dm?: boolean;
|
||||
};
|
||||
|
||||
export function SidebarTab({
|
||||
icon,
|
||||
selected,
|
||||
tooltip,
|
||||
onClick,
|
||||
menu,
|
||||
menuAnchor,
|
||||
unreadHighlight = false,
|
||||
unreadCount = 0,
|
||||
dm = false,
|
||||
}: SidebarTabProps) {
|
||||
const { anchor, close, triggerProps } = menuAnchor;
|
||||
|
||||
return (
|
||||
<SidebarItemLeft active={selected}>
|
||||
<SidebarItemTooltip tooltip={tooltip}>
|
||||
{(triggerRef) => (
|
||||
<ResponsiveMenu
|
||||
anchor={anchor}
|
||||
requestClose={close}
|
||||
position="Right"
|
||||
align="Start"
|
||||
menu={menu}
|
||||
>
|
||||
<SidebarAvatar
|
||||
as="button"
|
||||
ref={triggerRef}
|
||||
outlined
|
||||
onClick={onClick}
|
||||
onContextMenu={triggerProps.onContextMenu}
|
||||
onTouchStart={triggerProps.onTouchStart}
|
||||
onTouchEnd={triggerProps.onTouchEnd}
|
||||
onTouchMove={triggerProps.onTouchMove}
|
||||
onTouchCancel={triggerProps.onTouchCancel}
|
||||
>
|
||||
{icon}
|
||||
</SidebarAvatar>
|
||||
</ResponsiveMenu>
|
||||
)}
|
||||
</SidebarItemTooltip>
|
||||
{unreadCount > 0 && (
|
||||
<SidebarUnreadBadge highlight={unreadHighlight} count={unreadCount} dm={dm} />
|
||||
)}
|
||||
</SidebarItemLeft>
|
||||
);
|
||||
}
|
||||
@@ -4,3 +4,4 @@ export * from './SidebarUnreadBadge';
|
||||
export * from './SidebarContent';
|
||||
export * from './SidebarStack';
|
||||
export * from './SidebarStackSeparator';
|
||||
export * from './SidebarTab';
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Box, as, toRem } from 'folds';
|
||||
import * as css from './TypingIndicator.css';
|
||||
|
||||
export type TypingIndicatorProps = {
|
||||
type TypingIndicatorProps = {
|
||||
size?: '300' | '400';
|
||||
disableAnimation?: boolean;
|
||||
};
|
||||
|
||||
@@ -42,7 +42,7 @@ async function oEmbedData(url: string): Promise<OEmbed> {
|
||||
return response.json();
|
||||
}
|
||||
|
||||
export type EmbedHeaderProps = {
|
||||
type EmbedHeaderProps = {
|
||||
title: string;
|
||||
source: string;
|
||||
after?: ReactNode;
|
||||
|
||||
@@ -44,7 +44,7 @@ import { useRoomNavigate } from '$hooks/useRoomNavigate';
|
||||
import { useDirectRooms } from '$pages/client/direct/useDirectRooms';
|
||||
import { useMediaAuthentication } from '$hooks/useMediaAuthentication';
|
||||
import { useAllJoinedRoomsSet, useGetRoom } from '$hooks/useGetRoom';
|
||||
import { getDirectRoomAvatarUrl, getRoomAvatarUrl } from '$utils/room';
|
||||
import { getDirectRoomAvatarUrl, getRoomAvatarUrl } from '$utils/room/display';
|
||||
import { nameInitials } from '$utils/common';
|
||||
import { getMatrixToUser } from '$plugins/matrix-to';
|
||||
import { useTimeoutToggle } from '$hooks/useTimeoutToggle';
|
||||
|
||||
@@ -220,13 +220,13 @@ export function UserHero({
|
||||
size="T200"
|
||||
style={{
|
||||
flex: 1,
|
||||
wordBreak: 'break-word',
|
||||
display: '-webkit-box',
|
||||
overflowWrap: 'anywhere',
|
||||
WebkitLineClamp: 2,
|
||||
WebkitBoxOrient: 'vertical',
|
||||
overflow: 'hidden',
|
||||
opacity: allowEditing && !status ? config.opacity.Placeholder : 1,
|
||||
}}
|
||||
truncate={allowEditing}
|
||||
>
|
||||
{status || (allowEditing && "What's on your mind?")}
|
||||
</Text>
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
import { Box, Button, color, config, Spinner, Text, Input } from 'folds';
|
||||
import { Box, config, Spinner, Text, Input } from 'folds';
|
||||
import { ArrowLeft, ArrowRight, profileIcon, Prohibit } from '$components/icons/phosphor';
|
||||
import { useCallback, useRef } from 'react';
|
||||
import { useRoom } from '$hooks/useRoom';
|
||||
import { AsyncStatus, useAsyncCallback } from '$hooks/useAsyncCallback';
|
||||
import { AsyncError } from '$components/AsyncError';
|
||||
import { useMatrixClient } from '$hooks/useMatrixClient';
|
||||
import { BreakWord } from '$styles/Text.css';
|
||||
import { useSetting } from '$state/hooks/settings';
|
||||
import { settingsAtom } from '$state/settings';
|
||||
import { timeDayMonYear, timeHourMinute } from '$utils/time';
|
||||
import { SettingTile } from '$components/setting-tile';
|
||||
import { CutoutCard } from '$components/cutout-card';
|
||||
import { Button } from '$components/button';
|
||||
|
||||
type UserKickAlertProps = {
|
||||
reason?: string;
|
||||
@@ -79,7 +80,6 @@ export function UserBanAlert({ userId, reason, canUnban, bannedBy, ts }: UserBan
|
||||
}, [mx, room, userId])
|
||||
);
|
||||
const banning = unbanState.status === AsyncStatus.Loading;
|
||||
const error = unbanState.status === AsyncStatus.Error;
|
||||
|
||||
return (
|
||||
<CutoutCard style={{ padding: config.space.S200 }} variant="Critical">
|
||||
@@ -109,19 +109,17 @@ export function UserBanAlert({ userId, reason, canUnban, bannedBy, ts }: UserBan
|
||||
)}
|
||||
</Text>
|
||||
</Box>
|
||||
{error && (
|
||||
<Text className={BreakWord} size="T200" style={{ color: color.Critical.Main }}>
|
||||
<b>{unbanState.error.message}</b>
|
||||
</Text>
|
||||
)}
|
||||
<AsyncError state={unbanState} bold />
|
||||
{canUnban && (
|
||||
<Button
|
||||
size="300"
|
||||
variant="Critical"
|
||||
radii="300"
|
||||
onClick={unban}
|
||||
before={banning && <Spinner size="100" variant="Critical" fill="Solid" />}
|
||||
disabled={banning}
|
||||
loading={banning}
|
||||
spinnerSize="100"
|
||||
spinnerVariant="Critical"
|
||||
spinnerFill="Solid"
|
||||
>
|
||||
<Text size="B300">Unban</Text>
|
||||
</Button>
|
||||
@@ -154,7 +152,6 @@ export function UserInviteAlert({ userId, reason, canKick, invitedBy, ts }: User
|
||||
}, [mx, room, userId])
|
||||
);
|
||||
const kicking = kickState.status === AsyncStatus.Loading;
|
||||
const error = kickState.status === AsyncStatus.Error;
|
||||
|
||||
return (
|
||||
<CutoutCard style={{ padding: config.space.S200 }} variant="Success">
|
||||
@@ -184,11 +181,7 @@ export function UserInviteAlert({ userId, reason, canKick, invitedBy, ts }: User
|
||||
)}
|
||||
</Text>
|
||||
</Box>
|
||||
{error && (
|
||||
<Text className={BreakWord} size="T200" style={{ color: color.Critical.Main }}>
|
||||
<b>{kickState.error.message}</b>
|
||||
</Text>
|
||||
)}
|
||||
<AsyncError state={kickState} bold />
|
||||
{canKick && (
|
||||
<Button
|
||||
size="300"
|
||||
@@ -197,8 +190,10 @@ export function UserInviteAlert({ userId, reason, canKick, invitedBy, ts }: User
|
||||
outlined
|
||||
radii="300"
|
||||
onClick={kick}
|
||||
before={kicking && <Spinner size="100" variant="Success" fill="Soft" />}
|
||||
disabled={kicking}
|
||||
loading={kicking}
|
||||
spinnerSize="100"
|
||||
spinnerVariant="Success"
|
||||
spinnerFill="Soft"
|
||||
>
|
||||
<Text size="B300">Cancel Invite</Text>
|
||||
</Button>
|
||||
@@ -268,21 +263,9 @@ export function UserModeration({ userId, canKick, canBan, canInvite }: UserModer
|
||||
radii="300"
|
||||
disabled={disabled}
|
||||
/>
|
||||
{kickState.status === AsyncStatus.Error && (
|
||||
<Text style={{ color: color.Critical.Main }} className={BreakWord} size="T200">
|
||||
<b>{kickState.error.message}</b>
|
||||
</Text>
|
||||
)}
|
||||
{banState.status === AsyncStatus.Error && (
|
||||
<Text style={{ color: color.Critical.Main }} className={BreakWord} size="T200">
|
||||
<b>{banState.error.message}</b>
|
||||
</Text>
|
||||
)}
|
||||
{inviteState.status === AsyncStatus.Error && (
|
||||
<Text style={{ color: color.Critical.Main }} className={BreakWord} size="T200">
|
||||
<b>{inviteState.error.message}</b>
|
||||
</Text>
|
||||
)}
|
||||
<AsyncError state={kickState} bold />
|
||||
<AsyncError state={banState} bold />
|
||||
<AsyncError state={inviteState} bold />
|
||||
</Box>
|
||||
<Box shrink="No" gap="200">
|
||||
{canInvite && (
|
||||
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
User,
|
||||
} from '$components/icons/phosphor';
|
||||
import { mxcUrlToHttp } from '$utils/matrix';
|
||||
import { getMemberAvatarMxc, getMemberDisplayName } from '$utils/room';
|
||||
import { getMemberAvatarMxc, getMemberDisplayName } from '$utils/room/display';
|
||||
import { useMatrixClient } from '$hooks/useMatrixClient';
|
||||
import { useMediaAuthentication } from '$hooks/useMediaAuthentication';
|
||||
import { usePowerLevels } from '$hooks/usePowerLevels';
|
||||
|
||||
@@ -3,16 +3,21 @@ import { color, config, toRem } from 'folds';
|
||||
|
||||
export const UserHero = style({
|
||||
position: 'relative',
|
||||
minWidth: 0,
|
||||
maxWidth: '100%',
|
||||
});
|
||||
|
||||
export const UserHeroCoverContainer = style({
|
||||
height: toRem(96),
|
||||
overflow: 'hidden',
|
||||
maxWidth: '100%',
|
||||
minWidth: 0,
|
||||
});
|
||||
|
||||
export const UserHeroCover = style({
|
||||
height: '100%',
|
||||
width: '100%',
|
||||
maxWidth: '100%',
|
||||
objectFit: 'cover',
|
||||
objectPosition: 'center',
|
||||
});
|
||||
@@ -26,6 +31,7 @@ export const UserHeroAvatarStatusContainer = style({
|
||||
position: 'relative',
|
||||
height: toRem(29),
|
||||
width: '100%',
|
||||
minWidth: 0,
|
||||
});
|
||||
export const UserHeroAvatarContainer = style({
|
||||
position: 'relative',
|
||||
|
||||
@@ -2,8 +2,6 @@ import to from 'await-to-js';
|
||||
import { trimTrailingSlash } from './utils/common';
|
||||
|
||||
export enum AutoDiscoveryAction {
|
||||
PROMPT = 'PROMPT',
|
||||
IGNORE = 'IGNORE',
|
||||
FAIL_PROMPT = 'FAIL_PROMPT',
|
||||
FAIL_ERROR = 'FAIL_ERROR',
|
||||
}
|
||||
|
||||
+1
-26
@@ -1,38 +1,13 @@
|
||||
export enum ErrorCode {
|
||||
M_FORBIDDEN = 'M_FORBIDDEN',
|
||||
M_UNKNOWN_TOKEN = 'M_UNKNOWN_TOKEN',
|
||||
M_MISSING_TOKEN = 'M_MISSING_TOKEN',
|
||||
M_BAD_JSON = 'M_BAD_JSON',
|
||||
M_NOT_JSON = 'M_NOT_JSON',
|
||||
M_NOT_FOUND = 'M_NOT_FOUND',
|
||||
M_LIMIT_EXCEEDED = 'M_LIMIT_EXCEEDED',
|
||||
M_UNRECOGNIZED = 'M_UNRECOGNIZED',
|
||||
M_UNKNOWN = 'M_UNKNOWN',
|
||||
|
||||
M_UNAUTHORIZED = 'M_UNAUTHORIZED',
|
||||
M_USER_DEACTIVATED = 'M_USER_DEACTIVATED',
|
||||
M_USER_IN_USE = 'M_USER_IN_USE',
|
||||
M_INVALID_USERNAME = 'M_INVALID_USERNAME',
|
||||
M_WEAK_PASSWORD = 'M_WEAK_PASSWORD',
|
||||
M_PASSWORD_TOO_SHORT = 'M_PASSWORD_TOO_SHORT',
|
||||
M_ROOM_IN_USE = 'M_ROOM_IN_USE',
|
||||
M_INVALID_ROOM_STATE = 'M_INVALID_ROOM_STATE',
|
||||
M_THREEPID_IN_USE = 'M_THREEPID_IN_USE',
|
||||
M_THREEPID_NOT_FOUND = 'M_THREEPID_NOT_FOUND',
|
||||
M_THREEPID_AUTH_FAILED = 'M_THREEPID_AUTH_FAILED',
|
||||
M_THREEPID_DENIED = 'M_THREEPID_DENIED',
|
||||
M_SERVER_NOT_TRUSTED = 'M_SERVER_NOT_TRUSTED',
|
||||
M_UNSUPPORTED_ROOM_VERSION = 'M_UNSUPPORTED_ROOM_VERSION',
|
||||
M_INCOMPATIBLE_ROOM_VERSION = 'M_INCOMPATIBLE_ROOM_VERSION',
|
||||
M_BAD_STATE = 'M_BAD_STATE',
|
||||
M_GUEST_ACCESS_FORBIDDEN = 'M_GUEST_ACCESS_FORBIDDEN',
|
||||
M_CAPTCHA_NEEDED = 'M_CAPTCHA_NEEDED',
|
||||
M_CAPTCHA_INVALID = 'M_CAPTCHA_INVALID',
|
||||
M_MISSING_PARAM = 'M_MISSING_PARAM',
|
||||
M_INVALID_PARAM = 'M_INVALID_PARAM',
|
||||
M_TOO_LARGE = 'M_TOO_LARGE',
|
||||
|
||||
M_EXCLUSIVE = 'M_EXCLUSIVE',
|
||||
M_RESOURCE_LIMIT_EXCEEDED = 'M_RESOURCE_LIMIT_EXCEEDED',
|
||||
M_CANNOT_LEAVE_SERVER_NOTICE_ROOM = 'M_CANNOT_LEAVE_SERVER_NOTICE_ROOM',
|
||||
M_MAX_DELAY_EXCEEDED = 'M_MAX_DELAY_EXCEEDED',
|
||||
}
|
||||
@@ -33,7 +33,7 @@ import { mDirectAtom } from '$state/mDirectList';
|
||||
import { roomToParentsAtom } from '$state/room/roomToParents';
|
||||
import { useAllJoinedRoomsSet, useGetRoom } from '$hooks/useGetRoom';
|
||||
import { VirtualTile } from '$components/virtualizer';
|
||||
import { getDirectRoomAvatarUrl, getRoomAvatarUrl } from '$utils/room';
|
||||
import { getDirectRoomAvatarUrl, getRoomAvatarUrl } from '$utils/room/display';
|
||||
import { RoomAvatar, RoomIcon } from '$components/room-avatar';
|
||||
import { nameInitials } from '$utils/common';
|
||||
import { useMediaAuthentication } from '$hooks/useMediaAuthentication';
|
||||
|
||||
@@ -4,7 +4,7 @@ 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 { getAllParents, guessPerfectParent } from '../../utils/room/hierarchy';
|
||||
import { useOrphanSpaces } from '../../state/hooks/roomList';
|
||||
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
||||
import { allRoomsAtom } from '../../state/room-list/roomList';
|
||||
|
||||
@@ -3,7 +3,7 @@ import { CaretDown, CaretUp, sizedIcon, userFallbackIcon } from '$components/ico
|
||||
import type { CallMembership } from '$types/matrix-sdk';
|
||||
import type { Room } from '$types/matrix-sdk';
|
||||
import * as css from './styles.css';
|
||||
import { getMemberAvatarMxc, getMemberDisplayName } from '../../utils/room';
|
||||
import { getMemberAvatarMxc, getMemberDisplayName } from '../../utils/room/display';
|
||||
import { getMxIdLocalPart, mxcUrlToHttp } from '../../utils/matrix';
|
||||
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
||||
import { useMediaAuthentication } from '../../hooks/useMediaAuthentication';
|
||||
|
||||
@@ -3,7 +3,7 @@ import type { CallMembership } from '$types/matrix-sdk';
|
||||
import type { Room } from '$types/matrix-sdk';
|
||||
import { UserAvatar } from '../../components/user-avatar';
|
||||
import { userFallbackIcon } from '$components/icons/phosphor';
|
||||
import { getMemberAvatarMxc, getMemberDisplayName } from '../../utils/room';
|
||||
import { getMemberAvatarMxc, getMemberDisplayName } from '../../utils/room/display';
|
||||
import { getMxIdLocalPart, mxcUrlToHttp } from '../../utils/matrix';
|
||||
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
||||
import { useMediaAuthentication } from '../../hooks/useMediaAuthentication';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { Room } from '$types/matrix-sdk';
|
||||
import { Box, Text } from 'folds';
|
||||
import { sizedIcon, Microphone } from '$components/icons/phosphor';
|
||||
import { getMemberDisplayName } from '../../utils/room';
|
||||
import { getMemberDisplayName } from '../../utils/room/display';
|
||||
import { getMxIdLocalPart } from '../../utils/matrix';
|
||||
|
||||
type MemberSpeakingProps = {
|
||||
|
||||
@@ -12,7 +12,7 @@ import { useMatrixClient } from '../../hooks/useMatrixClient';
|
||||
import { useMediaAuthentication } from '../../hooks/useMediaAuthentication';
|
||||
import { useOpenUserRoomProfile } from '../../state/hooks/userRoomProfile';
|
||||
import { SequenceCard } from '../../components/sequence-card';
|
||||
import { getMemberAvatarMxc, getMemberDisplayName } from '../../utils/room';
|
||||
import { getMemberAvatarMxc, getMemberDisplayName } from '../../utils/room/display';
|
||||
import { useRoom } from '../../hooks/useRoom';
|
||||
import { getMxIdLocalPart, mxcUrlToHttp } from '../../utils/matrix';
|
||||
import { UserAvatar } from '../../components/user-avatar';
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Badge, Box, color, Header, Scroll, Text, toRem } from 'folds';
|
||||
import { useAtomValue } from 'jotai';
|
||||
import { ContainerColor } from '$styles/ContainerColor.css';
|
||||
import { useRoom } from '$hooks/useRoom';
|
||||
import { useCallStartCapabilities } from '$hooks/useCallStartCapabilities';
|
||||
import { useCallStartCapabilities } from './useCallStartCapabilities';
|
||||
|
||||
import { useCallMembers, useCallSession } from '$hooks/useCall';
|
||||
import { useCallEmbed, useCallEmbedPlacementSync, useCallJoined } from '$hooks/useCallEmbed';
|
||||
|
||||
File renamed without changes.
+3
-3
@@ -30,7 +30,7 @@ vi.mock('$hooks/useRoomMeta', () => ({
|
||||
useRoomName: () => 'Direct Message',
|
||||
}));
|
||||
|
||||
vi.mock(import('$utils/room'), async (importOriginal) => ({
|
||||
vi.mock(import('$utils/room/display'), async (importOriginal) => ({
|
||||
...(await importOriginal()),
|
||||
getRoomAvatarUrl: () => undefined,
|
||||
getMemberDisplayName: () => 'Alice',
|
||||
@@ -46,11 +46,11 @@ vi.mock('$utils/rtc', () => ({
|
||||
webRTCSupported: () => webRtcSupportedMock(),
|
||||
}));
|
||||
|
||||
vi.mock('./room-avatar', () => ({
|
||||
vi.mock('$components/room-avatar', () => ({
|
||||
RoomAvatar: ({ alt }: { alt: string }) => <div>{alt}</div>,
|
||||
}));
|
||||
|
||||
vi.mock('./user-avatar', () => ({
|
||||
vi.mock('$components/user-avatar', () => ({
|
||||
UserAvatar: ({ alt }: { alt?: string }) => <div>{alt}</div>,
|
||||
}));
|
||||
|
||||
+4
-4
@@ -6,7 +6,7 @@ import { useMediaAuthentication } from '$hooks/useMediaAuthentication';
|
||||
import { useRoomName } from '$hooks/useRoomMeta';
|
||||
import { useCallEmbed } from '$hooks/useCallEmbed';
|
||||
import { getMxIdLocalPart } from '$utils/matrix';
|
||||
import { getAvatarUrl, getMemberDisplayName, getRoomAvatarUrl } from '$utils/room';
|
||||
import { getAvatarUrl, getMemberDisplayName, getRoomAvatarUrl } from '$utils/room/display';
|
||||
import { webRTCSupported } from '$utils/rtc';
|
||||
import { useRoomNavigate } from '$hooks/useRoomNavigate';
|
||||
import * as Sentry from '@sentry/react';
|
||||
@@ -21,8 +21,8 @@ import {
|
||||
import { createDebugLogger } from '$utils/debugLogger';
|
||||
import { dismissSystemCallNotifications } from '$features/call/callNotificationBridge';
|
||||
import { getIncomingCallBlockers } from '$features/call/getIncomingCallBlockers';
|
||||
import { RoomAvatar } from './room-avatar';
|
||||
import { UserAvatar } from './user-avatar';
|
||||
import { RoomAvatar } from '$components/room-avatar';
|
||||
import { UserAvatar } from '$components/user-avatar';
|
||||
import {
|
||||
composerIcon,
|
||||
menuIcon,
|
||||
@@ -33,7 +33,7 @@ import {
|
||||
User,
|
||||
sizedIcon,
|
||||
} from '$components/icons/phosphor';
|
||||
import { ModalOverlay } from './modal-overlay/ModalOverlay';
|
||||
import { ModalOverlay } from '$components/modal-overlay/ModalOverlay';
|
||||
import * as css from './IncomingCallModal.css';
|
||||
|
||||
const debugLog = createDebugLogger('IncomingCall');
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import type { Room } from '$types/matrix-sdk';
|
||||
import { evaluateCallStartCapabilities } from '$features/call/callStartCapabilities';
|
||||
import { evaluateCallStartCapabilities } from './callStartCapabilities';
|
||||
|
||||
const createRoom = (roomId: string, canSend = true): Room =>
|
||||
({
|
||||
@@ -40,8 +40,8 @@ import {
|
||||
} from '$features/call/callMembershipState';
|
||||
import { ringtoneManager } from '$features/call/CallRingtoneManager';
|
||||
import { OUTGOING_RING_TIMEOUT_MS } from '$features/call/callSignalingPolicy';
|
||||
import { useMatrixClient } from './useMatrixClient';
|
||||
import { createDebugLogger } from '../utils/debugLogger';
|
||||
import { useMatrixClient } from '$hooks/useMatrixClient';
|
||||
import { createDebugLogger } from '$utils/debugLogger';
|
||||
|
||||
const debugLog = createDebugLogger('CallSignaling');
|
||||
|
||||
File renamed without changes.
@@ -1,5 +1,5 @@
|
||||
import type { ChangeEvent, ChangeEventHandler, FormEventHandler } from 'react';
|
||||
import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import {
|
||||
Box,
|
||||
Text,
|
||||
@@ -11,7 +11,6 @@ import {
|
||||
config,
|
||||
Button,
|
||||
Spinner,
|
||||
Modal,
|
||||
} from 'folds';
|
||||
import { menuIcon, X } from '$components/icons/phosphor';
|
||||
import { PageContent, SettingsSectionPage } from '$components/page';
|
||||
@@ -35,20 +34,12 @@ import { AsyncStatus, useAsyncCallback } from '$hooks/useAsyncCallback';
|
||||
import type { Room, RoomMember, StateEvents } from '$types/matrix-sdk';
|
||||
import { Command, useCommands } from '$hooks/useCommands';
|
||||
import { useCapabilities } from '$hooks/useCapabilities';
|
||||
import { useObjectURL } from '$hooks/useObjectURL';
|
||||
import type { UploadSuccess } from '$state/upload';
|
||||
import { createUploadAtom } from '$state/upload';
|
||||
import { useFilePicker } from '$hooks/useFilePicker';
|
||||
import { CompactUploadCardRenderer } from '$components/upload-card';
|
||||
import { ImageEditor } from '$components/image-editor';
|
||||
import { ModalWide } from '$styles/Modal.css';
|
||||
import { NameColorEditor } from '$features/settings/account/NameColorEditor';
|
||||
import { PronounEditor } from '$features/settings/account/PronounEditor';
|
||||
import type { PronounSet } from '$utils/pronouns';
|
||||
import { EventType } from '$types/matrix-sdk';
|
||||
import { CustomStateEvent } from '$types/matrix/room';
|
||||
import { ModalOverlay } from '$components/modal-overlay/ModalOverlay';
|
||||
import { confirm } from '$components/confirm/confirm';
|
||||
import { AvatarUploadTile } from '$components/avatar-upload-tile/AvatarUploadTile';
|
||||
|
||||
const log = createLogger('Cosmetics');
|
||||
|
||||
@@ -80,45 +71,17 @@ function CosmeticsAvatar({ profile, member, userId, room }: CosmeticsSettingProp
|
||||
const avatarUrl =
|
||||
avatarMxc && (mxcUrlToHttp(mx, avatarMxc, useAuthentication, 96, 96, 'crop') ?? undefined);
|
||||
|
||||
const [imageFile, setImageFile] = useState<File>();
|
||||
const imageFileURL = useObjectURL(imageFile);
|
||||
const uploadAtom = useMemo(() => {
|
||||
if (imageFile) return createUploadAtom(imageFile);
|
||||
return undefined;
|
||||
}, [imageFile]);
|
||||
|
||||
const pickFile = useFilePicker(setImageFile, false);
|
||||
|
||||
const handleRemoveUpload = useCallback(() => {
|
||||
setImageFile(undefined);
|
||||
}, []);
|
||||
|
||||
const myRoomAvatar = useCommands(mx, room)[Command.MyRoomAvatar];
|
||||
const handleUploaded = useCallback(
|
||||
(upload: UploadSuccess) => {
|
||||
const { mxc } = upload;
|
||||
myRoomAvatar.exe(mxc).finally(() => {
|
||||
handleRemoveUpload();
|
||||
});
|
||||
},
|
||||
[myRoomAvatar, handleRemoveUpload]
|
||||
);
|
||||
|
||||
const handleRemoveAvatar = async () => {
|
||||
const ok = await confirm({
|
||||
title: 'Remove Room Avatar',
|
||||
description: 'Are you sure you want to remove room avatar?',
|
||||
action: 'Remove',
|
||||
variant: 'Critical',
|
||||
});
|
||||
if (ok) {
|
||||
myRoomAvatar.exe('');
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<SettingTile
|
||||
<AvatarUploadTile
|
||||
title="Room Avatar"
|
||||
disableSetAvatar={disableSetAvatar}
|
||||
removeDisabled={!hasRoomAvatarOverride}
|
||||
onUpload={(mxc) => myRoomAvatar.exe(mxc)}
|
||||
onRemove={() => myRoomAvatar.exe('')}
|
||||
confirmTitle="Remove Room Avatar"
|
||||
confirmDescription="Are you sure you want to remove room avatar?"
|
||||
after={
|
||||
<Avatar size="500" radii="300">
|
||||
<UserAvatar
|
||||
@@ -132,55 +95,7 @@ function CosmeticsAvatar({ profile, member, userId, room }: CosmeticsSettingProp
|
||||
/>
|
||||
</Avatar>
|
||||
}
|
||||
>
|
||||
{uploadAtom ? (
|
||||
<Box gap="200" direction="Column">
|
||||
<CompactUploadCardRenderer
|
||||
uploadAtom={uploadAtom}
|
||||
onRemove={handleRemoveUpload}
|
||||
onComplete={handleUploaded}
|
||||
/>
|
||||
</Box>
|
||||
) : (
|
||||
<Box gap="200">
|
||||
<Button
|
||||
onClick={() => pickFile('image/*')}
|
||||
size="300"
|
||||
variant="Secondary"
|
||||
fill="Soft"
|
||||
outlined
|
||||
radii="300"
|
||||
disabled={disableSetAvatar}
|
||||
>
|
||||
<Text size="B300">Upload</Text>
|
||||
</Button>
|
||||
{hasRoomAvatarOverride && (
|
||||
<Button
|
||||
size="300"
|
||||
variant="Critical"
|
||||
fill="None"
|
||||
radii="300"
|
||||
disabled={disableSetAvatar}
|
||||
onClick={handleRemoveAvatar}
|
||||
>
|
||||
<Text size="B300">Remove</Text>
|
||||
</Button>
|
||||
)}
|
||||
</Box>
|
||||
)}
|
||||
|
||||
{imageFileURL && (
|
||||
<ModalOverlay open={false} requestClose={handleRemoveUpload}>
|
||||
<Modal className={ModalWide} variant="Surface" size="500">
|
||||
<ImageEditor
|
||||
name={imageFile?.name ?? 'Unnamed'}
|
||||
url={imageFileURL}
|
||||
requestClose={handleRemoveUpload}
|
||||
/>
|
||||
</Modal>
|
||||
</ModalOverlay>
|
||||
)}
|
||||
</SettingTile>
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import { useRoomAccountData } from '$hooks/useRoomAccountData';
|
||||
import { roomToUnreadAtom } from '$state/room/roomToUnread';
|
||||
import { allRoomsAtom } from '$state/room-list/roomList';
|
||||
import { allInvitesAtom } from '$state/room-list/inviteList';
|
||||
import { isNotificationEvent } from '$utils/room';
|
||||
import { isNotificationEvent } from '$utils/room/unread';
|
||||
import { CutoutCard } from '$components/cutout-card';
|
||||
import type { AccountDataSubmitCallback } from '$components/AccountDataEditor';
|
||||
import { AccountDataEditor } from '$components/AccountDataEditor';
|
||||
|
||||
@@ -7,8 +7,6 @@ import {
|
||||
IconButton,
|
||||
Text,
|
||||
config,
|
||||
Button,
|
||||
Spinner,
|
||||
color,
|
||||
TextArea as TextAreaComponent,
|
||||
Input,
|
||||
@@ -20,8 +18,10 @@ import { useRoom } from '$hooks/useRoom';
|
||||
import { useAlive } from '$hooks/useAlive';
|
||||
import { useTextAreaCodeEditor } from '$hooks/useTextAreaCodeEditor';
|
||||
import { AsyncStatus, useAsyncCallback } from '$hooks/useAsyncCallback';
|
||||
import { AsyncError } from '$components/AsyncError';
|
||||
import { syntaxErrorPosition } from '$utils/dom';
|
||||
import { Cursor } from '$plugins/text-area';
|
||||
import { Button } from '$components/button';
|
||||
|
||||
const EDITOR_INTENT_SPACE_COUNT = 2;
|
||||
|
||||
@@ -157,18 +157,16 @@ export function SendRoomEvent({ type, stateKey, requestClose }: SendRoomEventPro
|
||||
size="400"
|
||||
radii="300"
|
||||
type="submit"
|
||||
disabled={submitting}
|
||||
before={submitting && <Spinner variant="Primary" fill="Solid" size="300" />}
|
||||
loading={submitting}
|
||||
spinnerSize="300"
|
||||
spinnerVariant="Primary"
|
||||
spinnerFill="Solid"
|
||||
>
|
||||
<Text size="B400">Send</Text>
|
||||
</Button>
|
||||
</Box>
|
||||
|
||||
{submitState.status === AsyncStatus.Error && (
|
||||
<Text size="T200" style={{ color: color.Critical.Main }}>
|
||||
<b>{submitState.error.message}</b>
|
||||
</Text>
|
||||
)}
|
||||
<AsyncError state={submitState} bold />
|
||||
</Box>
|
||||
{composeStateEvent && (
|
||||
<Box shrink="No" direction="Column" gap="100">
|
||||
|
||||
@@ -9,8 +9,6 @@ import {
|
||||
config,
|
||||
TextArea as TextAreaComponent,
|
||||
color,
|
||||
Spinner,
|
||||
Button,
|
||||
} from 'folds';
|
||||
import { ArrowLeft, composerIcon, menuIcon, X } from '$components/icons/phosphor';
|
||||
import type { MatrixError, StateEvents } from '$types/matrix-sdk';
|
||||
@@ -24,12 +22,14 @@ import { useMatrixClient } from '$hooks/useMatrixClient';
|
||||
import { useAlive } from '$hooks/useAlive';
|
||||
import { Cursor } from '$plugins/text-area';
|
||||
import { AsyncStatus, useAsyncCallback } from '$hooks/useAsyncCallback';
|
||||
import { AsyncError } from '$components/AsyncError';
|
||||
import { syntaxErrorPosition } from '$utils/dom';
|
||||
import { SettingTile } from '$components/setting-tile';
|
||||
import { usePowerLevels } from '$hooks/usePowerLevels';
|
||||
import { useTextAreaCodeEditor } from '$hooks/useTextAreaCodeEditor';
|
||||
import { useRoomCreators } from '$hooks/useRoomCreators';
|
||||
import { useRoomPermissions } from '$hooks/useRoomPermissions';
|
||||
import { Button } from '$components/button';
|
||||
|
||||
const EDITOR_INTENT_SPACE_COUNT = 2;
|
||||
|
||||
@@ -134,8 +134,10 @@ function StateEventEdit({ type, stateKey, content, requestClose }: StateEventEdi
|
||||
size="300"
|
||||
radii="300"
|
||||
type="submit"
|
||||
disabled={submitting}
|
||||
before={submitting && <Spinner variant="Primary" fill="Solid" size="300" />}
|
||||
loading={submitting}
|
||||
spinnerSize="300"
|
||||
spinnerVariant="Primary"
|
||||
spinnerFill="Solid"
|
||||
>
|
||||
<Text size="B300">Save</Text>
|
||||
</Button>
|
||||
@@ -154,11 +156,7 @@ function StateEventEdit({ type, stateKey, content, requestClose }: StateEventEdi
|
||||
/>
|
||||
</SequenceCard>
|
||||
|
||||
{submitState.status === AsyncStatus.Error && (
|
||||
<Text size="T200" style={{ color: color.Critical.Main }}>
|
||||
<b>{submitState.error.message}</b>
|
||||
</Text>
|
||||
)}
|
||||
<AsyncError state={submitState} bold />
|
||||
</Box>
|
||||
<Box grow="Yes" direction="Column" gap="100">
|
||||
<Box shrink="No">
|
||||
|
||||
@@ -3,14 +3,12 @@ import { useCallback, useMemo, useState } from 'react';
|
||||
import {
|
||||
Box,
|
||||
Text,
|
||||
Button,
|
||||
Avatar,
|
||||
AvatarImage,
|
||||
AvatarFallback,
|
||||
toRem,
|
||||
config,
|
||||
Input,
|
||||
Spinner,
|
||||
color,
|
||||
IconButton,
|
||||
Menu,
|
||||
@@ -36,6 +34,7 @@ import { useAlive } from '$hooks/useAlive';
|
||||
import { useRoomCreators } from '$hooks/useRoomCreators';
|
||||
import { useRoomPermissions } from '$hooks/useRoomPermissions';
|
||||
import { CustomStateEvent } from '$types/matrix/room';
|
||||
import { Button } from '$components/button';
|
||||
|
||||
function PackAvatarImage({ url }: { url: string }) {
|
||||
const resolved = useRenderableMediaUrl(url);
|
||||
@@ -128,8 +127,9 @@ function CreatePackTile({ packs, roomId }: Readonly<CreatePackTileProps>) {
|
||||
variant="Success"
|
||||
radii="300"
|
||||
type="submit"
|
||||
disabled={creating}
|
||||
before={creating && <Spinner size="200" variant="Success" fill="Solid" />}
|
||||
loading={creating}
|
||||
spinnerSize="200"
|
||||
spinnerVariant="Success"
|
||||
>
|
||||
<Text size="B400">Create</Text>
|
||||
</Button>
|
||||
@@ -339,7 +339,9 @@ export function RoomPacks({ onViewPack }: Readonly<RoomPacksProps>) {
|
||||
variant="Critical"
|
||||
radii="300"
|
||||
disabled={applyingChanges}
|
||||
before={applyingChanges && <Spinner variant="Critical" fill="Solid" size="100" />}
|
||||
loading={applyingChanges}
|
||||
spinnerVariant="Critical"
|
||||
spinnerSize="100"
|
||||
onClick={handleApplyChanges}
|
||||
>
|
||||
<Text size="B300">Delete</Text>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Badge, Button, color, Spinner, Text } from 'folds';
|
||||
import { Badge, Text } from 'folds';
|
||||
import { useCallback } from 'react';
|
||||
import type { MatrixError, StateEvents } from '$types/matrix-sdk';
|
||||
import type { StateEvents } from '$types/matrix-sdk';
|
||||
import { SequenceCard, SequenceCardStyle } from '$components/sequence-card';
|
||||
import { SettingTile } from '$components/setting-tile';
|
||||
import { useMatrixClient } from '$hooks/useMatrixClient';
|
||||
@@ -11,6 +11,8 @@ import { useStateEvent } from '$hooks/useStateEvent';
|
||||
import type { RoomPermissionsAPI } from '$hooks/useRoomPermissions';
|
||||
import { EventType } from '$types/matrix-sdk';
|
||||
import { confirm } from '$components/confirm/confirm';
|
||||
import { AsyncError } from '$components/AsyncError';
|
||||
import { Button } from '$components/button';
|
||||
|
||||
const ROOM_ENC_ALGO = 'm.megolm.v1.aes-sha2';
|
||||
|
||||
@@ -76,18 +78,16 @@ export function RoomEncryption({ permissions }: RoomEncryptionProps) {
|
||||
radii="300"
|
||||
disabled={!canEnable}
|
||||
onClick={handleEnable}
|
||||
before={enabling && <Spinner size="100" variant="Primary" fill="Solid" />}
|
||||
loading={enabling}
|
||||
spinnerVariant="Primary"
|
||||
spinnerSize="100"
|
||||
>
|
||||
<Text size="B300">Enable</Text>
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
>
|
||||
{enableState.status === AsyncStatus.Error && (
|
||||
<Text style={{ color: color.Critical.Main }} size="T200">
|
||||
{(enableState.error as MatrixError).message}
|
||||
</Text>
|
||||
)}
|
||||
<AsyncError state={enableState} />
|
||||
</SettingTile>
|
||||
</SequenceCard>
|
||||
);
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
import { useCallback, useMemo } from 'react';
|
||||
import { Button, color, Spinner, Text } from 'folds';
|
||||
import { Button, Spinner, Text } from 'folds';
|
||||
import { CaretDown, menuIcon } from '$components/icons/phosphor';
|
||||
import type {
|
||||
MatrixError,
|
||||
RoomHistoryVisibilityEventContent,
|
||||
StateEvents,
|
||||
} from '$types/matrix-sdk';
|
||||
import type { RoomHistoryVisibilityEventContent, StateEvents } from '$types/matrix-sdk';
|
||||
import { HistoryVisibility, EventType } from '$types/matrix-sdk';
|
||||
import { SequenceCard, SequenceCardStyle } from '$components/sequence-card';
|
||||
import { SettingTile } from '$components/setting-tile';
|
||||
@@ -14,6 +10,7 @@ import { useRoom } from '$hooks/useRoom';
|
||||
|
||||
import { AsyncStatus, useAsyncCallback } from '$hooks/useAsyncCallback';
|
||||
import { useStateEvent } from '$hooks/useStateEvent';
|
||||
import { AsyncError } from '$components/AsyncError';
|
||||
import type { RoomPermissionsAPI } from '$hooks/useRoomPermissions';
|
||||
import {
|
||||
SettingMenuSelector,
|
||||
@@ -114,11 +111,7 @@ export function RoomHistoryVisibility({ permissions }: RoomHistoryVisibilityProp
|
||||
/>
|
||||
}
|
||||
>
|
||||
{submitState.status === AsyncStatus.Error && (
|
||||
<Text style={{ color: color.Critical.Main }} size="T200">
|
||||
{(submitState.error as MatrixError).message}
|
||||
</Text>
|
||||
)}
|
||||
<AsyncError state={submitState} />
|
||||
</SettingTile>
|
||||
</SequenceCard>
|
||||
);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { useCallback, useMemo } from 'react';
|
||||
import { color, Text } from 'folds';
|
||||
import type { MatrixError, RoomJoinRulesEventContent, StateEvents } from '$types/matrix-sdk';
|
||||
import type { RoomJoinRulesEventContent, StateEvents } from '$types/matrix-sdk';
|
||||
import { JoinRule, RestrictedAllowType, EventType } from '$types/matrix-sdk';
|
||||
import { useAtomValue } from 'jotai';
|
||||
import type { ExtendedJoinRules } from '$components/JoinRulesSwitcher';
|
||||
@@ -17,7 +16,8 @@ import { useRoom } from '$hooks/useRoom';
|
||||
import { useStateEvent } from '$hooks/useStateEvent';
|
||||
import { useSpaceOptionally } from '$hooks/useSpace';
|
||||
import { AsyncStatus, useAsyncCallback } from '$hooks/useAsyncCallback';
|
||||
import { getStateEvents } from '$utils/room';
|
||||
import { getStateEvents } from '$utils/room/hierarchy';
|
||||
import { AsyncError } from '$components/AsyncError';
|
||||
import { useRecursiveChildSpaceScopeFactory, useSpaceChildren } from '$state/hooks/roomList';
|
||||
import { allRoomsAtom } from '$state/room-list/roomList';
|
||||
import { roomToParentsAtom } from '$state/room/roomToParents';
|
||||
@@ -137,11 +137,7 @@ export function RoomJoinRules({ permissions }: RoomJoinRulesProps) {
|
||||
/>
|
||||
}
|
||||
>
|
||||
{submitState.status === AsyncStatus.Error && (
|
||||
<Text style={{ color: color.Critical.Main }} size="T200">
|
||||
{(submitState.error as MatrixError).message}
|
||||
</Text>
|
||||
)}
|
||||
<AsyncError state={submitState} />
|
||||
</SettingTile>
|
||||
</SequenceCard>
|
||||
);
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { Avatar, Box, Button, Chip, color, config, Input, Spinner, Text, TextArea } from 'folds';
|
||||
import { Avatar, Box, Chip, config, Input, Text, TextArea } from 'folds';
|
||||
import { ArrowsClockwise, chipIcon, menuIcon, PencilSimple } from '$components/icons/phosphor';
|
||||
import type { FormEventHandler } from 'react';
|
||||
import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import { useAtomValue } from 'jotai';
|
||||
import Linkify from 'linkify-react';
|
||||
import classNames from 'classnames';
|
||||
import type { MatrixError, StateEvents } from '$types/matrix-sdk';
|
||||
import type { StateEvents } from '$types/matrix-sdk';
|
||||
import { JoinRule, EventType } from '$types/matrix-sdk';
|
||||
import { SequenceCard, SequenceCardStyle } from '$components/sequence-card';
|
||||
import { useRoom } from '$hooks/useRoom';
|
||||
@@ -34,6 +34,8 @@ import { CustomStateEvent } from '$types/matrix/room';
|
||||
import { SettingTile } from '$components/setting-tile';
|
||||
import { confirm } from '$components/confirm/confirm';
|
||||
import { reportMediaLoadFailure } from '$utils/mediaLoadDiagnostics';
|
||||
import { AsyncError } from '$components/AsyncError';
|
||||
import { Button } from '$components/button';
|
||||
|
||||
type RoomProfileEditProps = {
|
||||
canEditAvatar: boolean;
|
||||
@@ -259,19 +261,17 @@ function RoomProfileEdit({
|
||||
readOnly={!canEditTopic || submitting}
|
||||
/>
|
||||
</Box>
|
||||
{submitState.status === AsyncStatus.Error && (
|
||||
<Text size="T200" style={{ color: color.Critical.Main }}>
|
||||
{(submitState.error as MatrixError).message}
|
||||
</Text>
|
||||
)}
|
||||
<AsyncError state={submitState} />
|
||||
<Box gap="300">
|
||||
<Button
|
||||
type="submit"
|
||||
variant="Success"
|
||||
size="300"
|
||||
radii="300"
|
||||
disabled={uploadingAvatar || submitting}
|
||||
before={submitting && <Spinner size="100" variant="Success" fill="Solid" />}
|
||||
disabled={uploadingAvatar}
|
||||
loading={submitting}
|
||||
spinnerVariant="Success"
|
||||
spinnerSize="100"
|
||||
>
|
||||
<Text size="B300">Save</Text>
|
||||
</Button>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Box, color, Spinner, Switch, Text } from 'folds';
|
||||
import type { MatrixError, RoomJoinRulesEventContent } from '$types/matrix-sdk';
|
||||
import { Box, Spinner, Switch } from 'folds';
|
||||
import type { RoomJoinRulesEventContent } from '$types/matrix-sdk';
|
||||
import { JoinRule, EventType } from '$types/matrix-sdk';
|
||||
import { SequenceCard, SequenceCardStyle } from '$components/sequence-card';
|
||||
import { SettingTile } from '$components/setting-tile';
|
||||
@@ -11,6 +11,7 @@ import { useMatrixClient } from '$hooks/useMatrixClient';
|
||||
import { useStateEvent } from '$hooks/useStateEvent';
|
||||
import type { ExtendedJoinRules } from '$components/JoinRulesSwitcher';
|
||||
import type { RoomPermissionsAPI } from '$hooks/useRoomPermissions';
|
||||
import { AsyncError } from '$components/AsyncError';
|
||||
|
||||
type RoomPublishProps = {
|
||||
permissions: RoomPermissionsAPI;
|
||||
@@ -60,17 +61,8 @@ export function RoomPublish({ permissions }: RoomPublishProps) {
|
||||
</Box>
|
||||
}
|
||||
>
|
||||
{visibilityState.status === AsyncStatus.Error && (
|
||||
<Text style={{ color: color.Critical.Main }} size="T200">
|
||||
{(visibilityState.error as MatrixError).message}
|
||||
</Text>
|
||||
)}
|
||||
|
||||
{toggleState.status === AsyncStatus.Error && (
|
||||
<Text style={{ color: color.Critical.Main }} size="T200">
|
||||
{(toggleState.error as MatrixError).message}
|
||||
</Text>
|
||||
)}
|
||||
<AsyncError state={visibilityState} />
|
||||
<AsyncError state={toggleState} />
|
||||
</SettingTile>
|
||||
</SequenceCard>
|
||||
);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { Button, color, Spinner, Text, Dialog, Header, config, Box, IconButton } from 'folds';
|
||||
import { color, Text, Dialog, Header, config, Box, IconButton } from 'folds';
|
||||
import { composerIcon, X } from '$components/icons/phosphor';
|
||||
import type { MatrixError, RoomTombstoneEventContent } from '$types/matrix-sdk';
|
||||
import { Method, EventType } from '$types/matrix-sdk';
|
||||
@@ -24,6 +24,7 @@ import { useRoomCreators } from '$hooks/useRoomCreators';
|
||||
import { BreakWord } from '$styles/Text.css';
|
||||
import { creatorsSupported } from '$utils/roomSupport';
|
||||
import { ModalOverlay } from '$components/modal-overlay/ModalOverlay';
|
||||
import { Button } from '$components/button';
|
||||
|
||||
function RoomUpgradeDialog({ requestClose }: { requestClose: () => void }) {
|
||||
const mx = useMatrixClient();
|
||||
@@ -121,8 +122,9 @@ function RoomUpgradeDialog({ requestClose }: { requestClose: () => void }) {
|
||||
<Button
|
||||
onClick={handleUpgradeRoom}
|
||||
variant="Secondary"
|
||||
disabled={upgrading}
|
||||
before={upgrading && <Spinner size="200" variant="Secondary" fill="Solid" />}
|
||||
loading={upgrading}
|
||||
spinnerVariant="Secondary"
|
||||
spinnerSize="200"
|
||||
>
|
||||
<Text size="B400">{room.isSpaceRoom() ? 'Upgrade Space' : 'Upgrade Room'}</Text>
|
||||
</Button>
|
||||
|
||||
@@ -27,7 +27,7 @@ import { ServerBadge } from '$components/server-badge';
|
||||
import { useDebounce } from '$hooks/useDebounce';
|
||||
import type { SearchItemStrGetter, UseAsyncSearchOptions } from '$hooks/useAsyncSearch';
|
||||
import { useAsyncSearch } from '$hooks/useAsyncSearch';
|
||||
import { getMemberSearchStr } from '$utils/room';
|
||||
import { getMemberSearchStr } from '$utils/room/display';
|
||||
import { useMembershipFilter, useMembershipFilterMenu } from '$hooks/useMemberFilter';
|
||||
import { useMemberPowerSort, useMemberSort, useMemberSortMenu } from '$hooks/useMemberSort';
|
||||
import { settingsAtom } from '$state/settings';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import { Badge, Box, Button, Chip, config, Menu, Spinner, Text } from 'folds';
|
||||
import { Badge, Box, Chip, config, Menu, Text } from 'folds';
|
||||
import { CaretDown, CaretUp, chipIcon } from '$components/icons/phosphor';
|
||||
import { produce } from 'immer';
|
||||
import { SequenceCard, SequenceCardStyle } from '$components/sequence-card';
|
||||
@@ -16,6 +16,7 @@ import { AsyncStatus, useAsyncCallback } from '$hooks/useAsyncCallback';
|
||||
import { useAlive } from '$hooks/useAlive';
|
||||
import type { PermissionGroup } from './types';
|
||||
import { EventType } from '$types/matrix-sdk';
|
||||
import { Button } from '$components/button';
|
||||
|
||||
const USER_DEFAULT_LOCATION: PermissionLocation = {
|
||||
user: true,
|
||||
@@ -270,7 +271,9 @@ export function PermissionGroups({
|
||||
variant="Success"
|
||||
radii="300"
|
||||
disabled={applyingChanges}
|
||||
before={applyingChanges && <Spinner variant="Success" fill="Solid" size="100" />}
|
||||
loading={applyingChanges}
|
||||
spinnerVariant="Success"
|
||||
spinnerSize="100"
|
||||
onClick={handleApplyChanges}
|
||||
>
|
||||
<Text size="B300">Apply Changes</Text>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Box, Button, color, config, Input, Spinner, Switch, Text } from 'folds';
|
||||
import { Box, color, config, Input, Switch, Text } from 'folds';
|
||||
import { sizedIcon, Warning } from '$components/icons/phosphor';
|
||||
import type { FormEventHandler } from 'react';
|
||||
import { useCallback, useState } from 'react';
|
||||
@@ -15,6 +15,7 @@ import { createRoomEncryptionState } from '$components/create-room';
|
||||
import { useAlive } from '$hooks/useAlive';
|
||||
import { getDirectRoomPath } from '$pages/pathUtils';
|
||||
import { ErrorCode } from '../../cs-errorcode';
|
||||
import { Button } from '$components/button';
|
||||
|
||||
type CreateChatProps = {
|
||||
defaultUserId?: string;
|
||||
@@ -146,9 +147,11 @@ export function CreateChat({ defaultUserId }: CreateChatProps) {
|
||||
variant="Primary"
|
||||
radii="400"
|
||||
disabled={disabled}
|
||||
before={loading && <Spinner variant="Primary" fill="Solid" size="200" />}
|
||||
loading={loading}
|
||||
spinnerVariant="Primary"
|
||||
spinnerSize="200"
|
||||
>
|
||||
<Text size="B500">Create</Text>
|
||||
<Text size="B400">Create Chat</Text>
|
||||
</Button>
|
||||
</Box>
|
||||
</Box>
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { ReactNode, FormEventHandler } from 'react';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import type { Room } from '$types/matrix-sdk';
|
||||
import { MatrixError, JoinRule, RoomType } from '$types/matrix-sdk';
|
||||
import { Box, Button, Chip, color, config, Input, Spinner, Switch, Text, TextArea } from 'folds';
|
||||
import { Box, Chip, color, config, Input, Switch, Text, TextArea } from 'folds';
|
||||
import { SettingTile } from '$components/setting-tile';
|
||||
import { SequenceCard } from '$components/sequence-card';
|
||||
import { useMatrixClient } from '$hooks/useMatrixClient';
|
||||
@@ -41,6 +41,7 @@ import {
|
||||
knockRestrictedSupported,
|
||||
} from '$utils/roomSupport';
|
||||
import { ErrorCode } from '../../cs-errorcode';
|
||||
import { Button } from '$components/button';
|
||||
|
||||
const debugLog = createDebugLogger('CreateRoom');
|
||||
|
||||
@@ -352,9 +353,11 @@ export function CreateRoomForm({
|
||||
variant="Primary"
|
||||
radii="400"
|
||||
disabled={disabled}
|
||||
before={loading && <Spinner variant="Primary" fill="Solid" size="200" />}
|
||||
loading={loading}
|
||||
spinnerVariant="Primary"
|
||||
spinnerSize="200"
|
||||
>
|
||||
<Text size="B500">Create</Text>
|
||||
<Text size="B400">Create Room</Text>
|
||||
</Button>
|
||||
</Box>
|
||||
</Box>
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { ReactNode, FormEventHandler } from 'react';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import type { Room } from '$types/matrix-sdk';
|
||||
import { MatrixError, RoomType } from '$types/matrix-sdk';
|
||||
import { Box, Button, Chip, color, config, Input, Spinner, Switch, Text, TextArea } from 'folds';
|
||||
import { Box, Chip, color, config, Input, Switch, Text, TextArea } from 'folds';
|
||||
import { SettingTile } from '$components/setting-tile';
|
||||
import { SequenceCard } from '$components/sequence-card';
|
||||
import { useMatrixClient } from '$hooks/useMatrixClient';
|
||||
@@ -37,6 +37,7 @@ import {
|
||||
} from '$components/icons/phosphor';
|
||||
|
||||
import { ErrorCode } from '../../cs-errorcode';
|
||||
import { Button } from '$components/button';
|
||||
|
||||
const getCreateSpaceAccessToIcon = (
|
||||
access: CreateRoomAccess,
|
||||
@@ -272,9 +273,11 @@ export function CreateSpaceForm({ defaultAccess, space, onCreate }: CreateSpaceF
|
||||
variant="Primary"
|
||||
radii="400"
|
||||
disabled={disabled}
|
||||
before={loading && <Spinner variant="Primary" fill="Solid" size="200" />}
|
||||
loading={loading}
|
||||
spinnerVariant="Primary"
|
||||
spinnerSize="200"
|
||||
>
|
||||
<Text size="B500">Create</Text>
|
||||
<Text size="B400">Create Space</Text>
|
||||
</Button>
|
||||
</Box>
|
||||
</Box>
|
||||
|
||||
@@ -40,7 +40,7 @@ import { getCanonicalAliasOrRoomId, rateLimitedActions } from '$utils/matrix';
|
||||
import { getSpaceRoomPath } from '$pages/pathUtils';
|
||||
|
||||
import { ASCIILexicalTable, orderKeys } from '$utils/ASCIILexicalTable';
|
||||
import { getStateEvent } from '$utils/room';
|
||||
import { getStateEvent } from '$utils/room/hierarchy';
|
||||
import { useClosedLobbyCategoriesAtom } from '$state/hooks/closedLobbyCategories';
|
||||
import {
|
||||
makeCinnySpacesContent,
|
||||
|
||||
Loaded 100 of 252 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user