mirror of
https://github.com/SableClient/Sable.git
synced 2026-11-20 17:11:17 -08:00
79 files changed
+5685
-4746
No files matched your search
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
Update `@sableclient/twemoji-font` to fix missing Twemoji emoji coverage.
|
||||
@@ -1,5 +1,33 @@
|
||||
# Sable Client Changelog
|
||||
|
||||
## 1.18.3 (2026-06-17)
|
||||
|
||||
### Fixes
|
||||
|
||||
* Fixed broken Twemoji rendering and updated emoji picker, autocomplete, and jumbo detection for new emojis. ([#957](<https://github.com/SableClient/Sable/pull/957>) by @7w1)
|
||||
* Updated various dependencies. ([#957](<https://github.com/SableClient/Sable/pull/957>) by @7w1)
|
||||
|
||||
## 1.18.2 (2026-06-17)
|
||||
|
||||
### Fixes
|
||||
|
||||
* Adding servers in the explore tab now persist in account data and are actually added to the list. ([#953](<https://github.com/SableClient/Sable/pull/953>) by @7w1)
|
||||
* Added a button to leave all rooms/subspaces within a space in the leave space confirmation dialog. Also has text to show number of children. ([#953](<https://github.com/SableClient/Sable/pull/953>) by @7w1)
|
||||
* Added a setting to play notification sounds when tab is in background, enabled by default. ([#953](<https://github.com/SableClient/Sable/pull/953>) by @7w1)
|
||||
* Centered the notification bell icon in the room list. ([#954](<https://github.com/SableClient/Sable/pull/954>) by @7w1)
|
||||
* Fixed edit diffs not properly scaling with zoom. ([#951](<https://github.com/SableClient/Sable/pull/951>) by @7w1)
|
||||
* Fixed icons not scaling with zoom. ([#951](<https://github.com/SableClient/Sable/pull/951>) by @7w1)
|
||||
* Fixed invalid language tag when no locale set for some systems. ([#953](<https://github.com/SableClient/Sable/pull/953>) by @7w1)
|
||||
* Fixed replying to reaction/edit events not replying. ([#942](<https://github.com/SableClient/Sable/pull/942>) by @7w1)
|
||||
* Fix sending thread messages sometimes sending in the general timeline ([#944](<https://github.com/SableClient/Sable/pull/944>) by @nushea)
|
||||
|
||||
#### Updates Twemoji to from v15 to v17 ([#950](<https://github.com/SableClient/Sable/pull/950>) by @7w1, @hazre)
|
||||
|
||||
You can check here for emoji changes:
|
||||
|
||||
- https://www.unicode.org/emoji/charts-16.0/emoji-released.html
|
||||
- https://www.unicode.org/emoji/charts-17.0/emoji-released.html
|
||||
|
||||
## 1.18.1 (2026-06-14)
|
||||
|
||||
### Fixes
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
;
|
||||
pname = "sable";
|
||||
fetcherVersion = 3;
|
||||
hash = "sha256-V+s9EQjEWjS8VOmd/MtvmUxExN96Ba8DpTqeQAyyuDU=";
|
||||
hash = "sha256-LdNWHVhUur064v6Nd+c7qENg7f7k0067Ty8tqBvDMys=";
|
||||
};
|
||||
|
||||
mkPnpmCheck =
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
"ignoreDependencies": [
|
||||
"buffer",
|
||||
"@sableclient/sable-call-embedded",
|
||||
"@matrix-org/matrix-sdk-crypto-wasm"
|
||||
"@matrix-org/matrix-sdk-crypto-wasm",
|
||||
"@sableclient/twemoji-font"
|
||||
],
|
||||
"ignoreBinaries": ["knope"],
|
||||
"rules": {
|
||||
|
||||
@@ -35,6 +35,21 @@ export default defineConfig({
|
||||
'typescript/no-unnecessary-type-arguments': 'off',
|
||||
'oxc/no-map-spread': 'off',
|
||||
'promise/always-return': 'off',
|
||||
'no-underscore-dangle': [
|
||||
'warn',
|
||||
{
|
||||
allow: [
|
||||
'_fetched',
|
||||
'__dirname',
|
||||
'__WB_MANIFEST',
|
||||
'_unstable_sendDelayedEvent',
|
||||
'_unstable_getDelayedEvents',
|
||||
'_unstable_updateDelayedEvent',
|
||||
'_unstable_sendDelayedStateEvent',
|
||||
'_unstable_getSharedRooms',
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
overrides: [
|
||||
{
|
||||
|
||||
+63
-57
@@ -1,13 +1,11 @@
|
||||
{
|
||||
"name": "sable",
|
||||
"version": "1.18.1",
|
||||
"version": "1.18.3",
|
||||
"description": "An almost stable Matrix client",
|
||||
"keywords": [],
|
||||
"license": "AGPL-3.0-only",
|
||||
"author": "7w1",
|
||||
"type": "module",
|
||||
"packageManager": "[email protected]+sha512.a706938f0e89ac1456b6563eab4edf1d1faf3368d1191fc5c59790e96dc918e4456ab2e67d613de1043d2e8c81f87303e6b40d4ffeca9df15ef1ad567348f2be",
|
||||
"engines": {
|
||||
"node": "24.x",
|
||||
"pnpm": ">=10"
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "vite dev",
|
||||
"build": "vite build",
|
||||
@@ -27,82 +25,80 @@
|
||||
"document-change": "knope document-change",
|
||||
"postinstall": "node scripts/install-knope.js"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "7w1",
|
||||
"license": "AGPL-3.0-only",
|
||||
"dependencies": {
|
||||
"@arborium/arborium": "^2.16.0",
|
||||
"@atlaskit/pragmatic-drag-and-drop": "^1.7.7",
|
||||
"@arborium/arborium": "^2.18.0",
|
||||
"@atlaskit/pragmatic-drag-and-drop": "^1.8.1",
|
||||
"@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^1.4.0",
|
||||
"@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.1.0",
|
||||
"@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.2.0",
|
||||
"@fontsource-variable/nunito": "5.2.7",
|
||||
"@fontsource/space-mono": "5.2.9",
|
||||
"@phosphor-icons/react": "^2.1.10",
|
||||
"@sentry/react": "^10.43.0",
|
||||
"@tanstack/react-query": "^5.90.21",
|
||||
"@tanstack/react-query-devtools": "^5.91.3",
|
||||
"@tanstack/react-virtual": "^3.13.19",
|
||||
"@sableclient/twemoji-font": "^1.0.4",
|
||||
"@sentry/react": "^10.58.0",
|
||||
"@tanstack/react-query": "^5.101.0",
|
||||
"@tanstack/react-query-devtools": "^5.101.0",
|
||||
"@tanstack/react-virtual": "^3.14.3",
|
||||
"@use-gesture/react": "10.3.1",
|
||||
"@vanilla-extract/css": "^1.18.0",
|
||||
"@vanilla-extract/css": "^1.20.1",
|
||||
"@vanilla-extract/recipes": "^0.5.7",
|
||||
"@vanilla-extract/vite-plugin": "^5.1.4",
|
||||
"@vanilla-extract/vite-plugin": "^5.2.2",
|
||||
"await-to-js": "^3.0.0",
|
||||
"badwords-list": "^2.0.1-4",
|
||||
"badwords-list": "2.0.1-4",
|
||||
"blurhash": "^2.0.5",
|
||||
"browser-encrypt-attachment": "^0.3.0",
|
||||
"chroma-js": "^3.2.0",
|
||||
"classnames": "^2.5.1",
|
||||
"dayjs": "^1.11.19",
|
||||
"dayjs": "^1.11.21",
|
||||
"domhandler": "^5.0.3",
|
||||
"dompurify": "^3.3.3",
|
||||
"emojibase": "^15.3.1",
|
||||
"emojibase-data": "^15.3.2",
|
||||
"dompurify": "^3.4.10",
|
||||
"emojibase": "^17.0.0",
|
||||
"emojibase-data": "^17.0.0",
|
||||
"eventemitter3": "^5.0.4",
|
||||
"file-saver": "^2.0.5",
|
||||
"focus-trap-react": "^10.3.1",
|
||||
"folds": "^2.6.2",
|
||||
"framer-motion": "12.34.3",
|
||||
"framer-motion": "^12.40.0",
|
||||
"html-dom-parser": "^5.1.8",
|
||||
"html-react-parser": "^4.2.10",
|
||||
"i18next": "^25.8.13",
|
||||
"i18next": "^25.10.10",
|
||||
"i18next-browser-languagedetector": "^8.2.1",
|
||||
"i18next-http-backend": "^2.7.3",
|
||||
"immer": "^9.0.21",
|
||||
"is-hotkey": "^0.2.0",
|
||||
"jotai": "^2.18.0",
|
||||
"katex": "^0.16.45",
|
||||
"jotai": "^2.20.1",
|
||||
"katex": "^0.16.47",
|
||||
"leaflet": "1.9.4",
|
||||
"linkify-react": "^4.3.2",
|
||||
"linkifyjs": "^4.3.2",
|
||||
"marked": "^18.0.2",
|
||||
"linkify-react": "^4.3.3",
|
||||
"linkifyjs": "^4.3.3",
|
||||
"marked": "^18.0.5",
|
||||
"matrix-js-sdk": "^38.4.0",
|
||||
"matrix-widget-api": "^1.16.1",
|
||||
"pdfjs-dist": "^5.4.624",
|
||||
"matrix-widget-api": "^1.17.0",
|
||||
"pdfjs-dist": "^5.7.284",
|
||||
"react": "^18.3.1",
|
||||
"react-aria": "^3.46.0",
|
||||
"react-aria": "^3.49.0",
|
||||
"react-blurhash": "^0.3.0",
|
||||
"react-colorful": "^5.6.1",
|
||||
"react-colorful": "^5.7.0",
|
||||
"react-dom": "^18.3.1",
|
||||
"react-google-recaptcha": "^2.1.0",
|
||||
"react-i18next": "^16.5.4",
|
||||
"react-i18next": "^16.6.6",
|
||||
"react-leaflet": "^4.2.1",
|
||||
"react-range": "^1.10.0",
|
||||
"react-router-dom": "^6.30.3",
|
||||
"slate": "^0.123.0",
|
||||
"slate-dom": "^0.123.0",
|
||||
"react-router-dom": "^6.30.4",
|
||||
"slate": "^0.124.1",
|
||||
"slate-dom": "^0.124.1",
|
||||
"slate-history": "^0.113.1",
|
||||
"slate-react": "^0.123.0",
|
||||
"slate-react": "^0.124.2",
|
||||
"ua-parser-js": "^1.0.41",
|
||||
"virtua": "^0.48.8",
|
||||
"workbox-precaching": "^7.4.0"
|
||||
"virtua": "^0.49.1",
|
||||
"workbox-precaching": "^7.4.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@cloudflare/vite-plugin": "^1.26.0",
|
||||
"@cloudflare/vite-plugin": "^1.41.0",
|
||||
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
|
||||
"@rollup/plugin-inject": "^5.0.5",
|
||||
"@rollup/plugin-wasm": "^6.2.2",
|
||||
"@sableclient/sable-call-embedded": "v1.1.4",
|
||||
"@sentry/vite-plugin": "^5.1.1",
|
||||
"@sableclient/sable-call-embedded": "1.1.4",
|
||||
"@sentry/vite-plugin": "^5.3.0",
|
||||
"@testing-library/jest-dom": "^6.9.1",
|
||||
"@testing-library/react": "^16.3.2",
|
||||
"@testing-library/user-event": "^14.6.1",
|
||||
@@ -111,28 +107,38 @@
|
||||
"@types/is-hotkey": "^0.1.10",
|
||||
"@types/leaflet": "^1.9.21",
|
||||
"@types/node": "24.10.13",
|
||||
"@types/react": "^18.3.28",
|
||||
"@types/react": "^18.3.31",
|
||||
"@types/react-dom": "^18.3.7",
|
||||
"@types/react-google-recaptcha": "^2.1.9",
|
||||
"@types/ua-parser-js": "^0.7.39",
|
||||
"@vitejs/plugin-react": "^5.1.4",
|
||||
"@vitest/coverage-v8": "^4.1.0",
|
||||
"@vitest/ui": "^4.1.0",
|
||||
"@vitejs/plugin-react": "^5.2.0",
|
||||
"@vitest/coverage-v8": "^4.1.9",
|
||||
"@vitest/ui": "^4.1.9",
|
||||
"buffer": "^6.0.3",
|
||||
"cloudflared": "^0.7.1",
|
||||
"jsdom": "^29.0.0",
|
||||
"jsdom": "^29.1.1",
|
||||
"knip": "5.85.0",
|
||||
"oxfmt": "^0.45.0",
|
||||
"oxlint": "^1.60.0",
|
||||
"oxlint-tsgolint": "^0.21.0",
|
||||
"oxlint": "^1.70.0",
|
||||
"oxlint-tsgolint": "^0.23.0",
|
||||
"typescript": "^5.9.3",
|
||||
"vite": "^7.3.1",
|
||||
"vite-plugin-compression2": "2.5.0",
|
||||
"vite-plugin-pwa": "^1.2.0",
|
||||
"vite-plugin-static-copy": "^3.2.0",
|
||||
"vite": "^7.3.5",
|
||||
"vite-plugin-compression2": "^2.5.3",
|
||||
"vite-plugin-pwa": "^1.3.0",
|
||||
"vite-plugin-static-copy": "^3.4.0",
|
||||
"vite-plugin-svgr": "4.5.0",
|
||||
"vite-plugin-top-level-await": "^1.6.0",
|
||||
"vitest": "^4.1.0",
|
||||
"wrangler": "^4.70.0"
|
||||
"vitest": "^4.1.9",
|
||||
"wrangler": "^4.101.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "24.x",
|
||||
"pnpm": ">=10"
|
||||
},
|
||||
"packageManager": "[email protected]+sha512.a706938f0e89ac1456b6563eab4edf1d1faf3368d1191fc5c59790e96dc918e4456ab2e67d613de1043d2e8c81f87303e6b40d4ffeca9df15ef1ad567348f2be",
|
||||
"pnpm": {
|
||||
"overrides": {
|
||||
"jsdom>undici": "^7.28.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
Generated
+3036
-3655
File diff suppressed because it is too large.
Load diff
@@ -10,6 +10,7 @@ engineStrict: true
|
||||
minimumReleaseAge: 1440
|
||||
minimumReleaseAgeExclude:
|
||||
- '@sableclient/sable-call-embedded'
|
||||
- '@sableclient/twemoji-font'
|
||||
|
||||
overrides:
|
||||
brace-expansion: '>=1.1.12'
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -102,11 +102,12 @@ function getSystemKnopePath() {
|
||||
);
|
||||
}
|
||||
|
||||
const toComparablePath = (value) => {
|
||||
const resolved = resolve(value);
|
||||
return process.platform === 'win32' ? resolved.toLowerCase() : resolved;
|
||||
};
|
||||
|
||||
function isPathWithin(candidatePath, rootPath) {
|
||||
const toComparablePath = (value) => {
|
||||
const resolved = resolve(value);
|
||||
return process.platform === 'win32' ? resolved.toLowerCase() : resolved;
|
||||
};
|
||||
const candidate = toComparablePath(candidatePath);
|
||||
const root = toComparablePath(rootPath);
|
||||
return candidate === root || candidate.startsWith(`${root}${sep}`);
|
||||
|
||||
@@ -4,7 +4,7 @@ import { Dialog, Header, Box, Text, IconButton, config, Button, Chip, color, Spi
|
||||
import { composerIcon, X } from '$components/icons/phosphor';
|
||||
import FileSaver from 'file-saver';
|
||||
import to from 'await-to-js';
|
||||
import type { AuthDict, IAuthData, UIAuthCallback } from '$types/matrix-sdk';
|
||||
import type { AuthDict, IAuthData, UIAuthCallback, UIAFlow } from '$types/matrix-sdk';
|
||||
import { MatrixError } from '$types/matrix-sdk';
|
||||
import { clearSecretStorageKeys } from '$client/secretStorageKeys';
|
||||
import { ContainerColor } from '$styles/ContainerColor.css';
|
||||
@@ -57,6 +57,32 @@ function makeUIAAction<T>(
|
||||
return action;
|
||||
}
|
||||
|
||||
function renderUnsupportedUIAFlow() {
|
||||
return (
|
||||
<Text size="T200">
|
||||
Authentication steps to perform this action are not supported by client.
|
||||
</Text>
|
||||
);
|
||||
}
|
||||
|
||||
type SetupVerificationUIAProps = {
|
||||
authData: IAuthData;
|
||||
ongoingFlow: UIAFlow;
|
||||
action: (authDict: AuthDict) => void;
|
||||
onCancel: () => void;
|
||||
};
|
||||
|
||||
function SetupVerificationUIA({
|
||||
authData,
|
||||
ongoingFlow,
|
||||
action,
|
||||
onCancel,
|
||||
}: SetupVerificationUIAProps) {
|
||||
return (
|
||||
<ActionUIA authData={authData} ongoingFlow={ongoingFlow} action={action} onCancel={onCancel} />
|
||||
);
|
||||
}
|
||||
|
||||
type SetupVerificationProps = {
|
||||
onComplete: (recoveryKey: string) => void;
|
||||
};
|
||||
@@ -169,6 +195,21 @@ function SetupVerification({ onComplete }: Readonly<SetupVerificationProps>) {
|
||||
setup(passphrase);
|
||||
};
|
||||
|
||||
const renderSetupVerificationUIA = useCallback(
|
||||
(ongoingFlow: UIAFlow) => {
|
||||
if (!uiaAction) return null;
|
||||
return (
|
||||
<SetupVerificationUIA
|
||||
authData={nextAuthData ?? uiaAction.authData}
|
||||
ongoingFlow={ongoingFlow}
|
||||
action={handleAction}
|
||||
onCancel={uiaAction.cancelCallback}
|
||||
/>
|
||||
);
|
||||
},
|
||||
[uiaAction, nextAuthData, handleAction]
|
||||
);
|
||||
|
||||
return (
|
||||
<Box as="form" onSubmit={handleSubmit} direction="Column" gap="400">
|
||||
<Text size="T300">
|
||||
@@ -194,20 +235,9 @@ function SetupVerification({ onComplete }: Readonly<SetupVerificationProps>) {
|
||||
{nextAuthData !== null && uiaAction && (
|
||||
<ActionUIAFlowsLoader
|
||||
authData={nextAuthData ?? uiaAction.authData}
|
||||
unsupported={() => (
|
||||
<Text size="T200">
|
||||
Authentication steps to perform this action are not supported by client.
|
||||
</Text>
|
||||
)}
|
||||
unsupported={renderUnsupportedUIAFlow}
|
||||
>
|
||||
{(ongoingFlow) => (
|
||||
<ActionUIA
|
||||
authData={nextAuthData ?? uiaAction.authData}
|
||||
ongoingFlow={ongoingFlow}
|
||||
action={handleAction}
|
||||
onCancel={uiaAction.cancelCallback}
|
||||
/>
|
||||
)}
|
||||
{renderSetupVerificationUIA}
|
||||
</ActionUIAFlowsLoader>
|
||||
)}
|
||||
</Box>
|
||||
|
||||
@@ -4,7 +4,7 @@ import type { ReactNode } from 'react';
|
||||
import { useMemo, useState } from 'react';
|
||||
import { useAtomValue } from 'jotai';
|
||||
import { config } from 'folds';
|
||||
import { ArrowBendUpLeftIcon, getPhosphorSize } from '$components/icons/phosphor';
|
||||
import { ArrowBendUpLeftIcon, getPhosphorIconSize } from '$components/icons/phosphor';
|
||||
import { mobileOrTablet } from '$utils/user-agent';
|
||||
import { RightSwipeAction, settingsAtom } from '$state/settings';
|
||||
|
||||
@@ -51,7 +51,7 @@ function ActiveSwipeWrapper({ children, onReply }: { children: ReactNode; onRepl
|
||||
>
|
||||
<motion.div style={{ opacity: iconOpacity }}>
|
||||
<ArrowBendUpLeftIcon
|
||||
size={getPhosphorSize().toolbar}
|
||||
size={getPhosphorIconSize('toolbar')}
|
||||
style={{
|
||||
color: isReady
|
||||
? 'var(--sable-surface-on-container)'
|
||||
|
||||
@@ -136,6 +136,12 @@ export const DEFAULT_PHOSPHOR_SIZES = {
|
||||
empty: 32,
|
||||
} as const;
|
||||
|
||||
export const PHOSPHOR_PX_PER_REM = 16;
|
||||
|
||||
export function phosphorSizeRem(px: number): string {
|
||||
return `${px / PHOSPHOR_PX_PER_REM}rem`;
|
||||
}
|
||||
|
||||
export type PhosphorRoleSizes = {
|
||||
compact: number;
|
||||
inline: number;
|
||||
@@ -200,6 +206,17 @@ function resolveIconTokenPx(
|
||||
}
|
||||
}
|
||||
|
||||
function resolveIconTokenSize(
|
||||
token: Exclude<IconSizeToken, 'Inherit'>,
|
||||
sizes: PhosphorRoleSizes
|
||||
): string {
|
||||
return phosphorSizeRem(resolveIconTokenPx(token, sizes));
|
||||
}
|
||||
|
||||
export function getPhosphorIconSize(role: keyof PhosphorRoleSizes): string {
|
||||
return phosphorSizeRem(getPhosphorSize()[role]);
|
||||
}
|
||||
|
||||
const timelineMutedStyle = { opacity: 0.6 } as const;
|
||||
|
||||
export type PhosphorIcon = ComponentType<IconProps>;
|
||||
@@ -220,7 +237,7 @@ export function sizedIcon(
|
||||
}
|
||||
return (
|
||||
<Icon
|
||||
size={resolveIconTokenPx(size, getPhosphorSize())}
|
||||
size={resolveIconTokenSize(size, getPhosphorSize())}
|
||||
weight={resolvedWeight}
|
||||
style={style}
|
||||
{...rest}
|
||||
@@ -229,19 +246,19 @@ export function sizedIcon(
|
||||
}
|
||||
|
||||
export function timelineIcon(Icon: PhosphorIcon, props?: IconProps): ReactNode {
|
||||
return <Icon size={getPhosphorSize().inline} style={timelineMutedStyle} {...props} />;
|
||||
return <Icon size={getPhosphorIconSize('inline')} style={timelineMutedStyle} {...props} />;
|
||||
}
|
||||
|
||||
export function menuIcon(Icon: PhosphorIcon, props?: IconProps): ReactNode {
|
||||
return <Icon size={getPhosphorSize().inline} {...props} />;
|
||||
return <Icon size={getPhosphorIconSize('inline')} {...props} />;
|
||||
}
|
||||
|
||||
export function composerIcon(Icon: PhosphorIcon, props?: IconProps): ReactNode {
|
||||
return <Icon size={getPhosphorSize().toolbar} {...props} />;
|
||||
return <Icon size={getPhosphorIconSize('toolbar')} {...props} />;
|
||||
}
|
||||
|
||||
export function chipIcon(Icon: PhosphorIcon, props?: IconProps): ReactNode {
|
||||
return <Icon size={getPhosphorSize().inline} {...props} />;
|
||||
return <Icon size={getPhosphorIconSize('inline')} {...props} />;
|
||||
}
|
||||
|
||||
export function profileIcon(Icon: PhosphorIcon, props?: SizedIconProps): ReactNode {
|
||||
@@ -260,17 +277,19 @@ export function chipCaretIcon(Icon: PhosphorIcon, props?: IconProps): ReactNode
|
||||
flexShrink: 0,
|
||||
}}
|
||||
>
|
||||
<Icon size={getPhosphorSize().inline} style={{ display: 'block', ...style }} {...rest} />
|
||||
<Icon size={getPhosphorIconSize('inline')} style={{ display: 'block', ...style }} {...rest} />
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
export function dropzoneIcon(Icon: PhosphorIcon, props?: IconProps): ReactNode {
|
||||
return <Icon size={getPhosphorSize().empty} {...props} />;
|
||||
return <Icon size={getPhosphorIconSize('empty')} {...props} />;
|
||||
}
|
||||
|
||||
export function settingsNavIcon(Icon: PhosphorIcon, active: boolean, props?: IconProps): ReactNode {
|
||||
return <Icon size={getPhosphorSize().inline} weight={active ? 'fill' : 'regular'} {...props} />;
|
||||
return (
|
||||
<Icon size={getPhosphorIconSize('inline')} weight={active ? 'fill' : 'regular'} {...props} />
|
||||
);
|
||||
}
|
||||
|
||||
export type UserFallbackSize = 'sm' | 'md' | 'lg' | 'xl' | 'hero';
|
||||
@@ -284,7 +303,7 @@ export function userFallbackIcon(size: UserFallbackSize = 'md', props?: IconProp
|
||||
xl: sizes.toolbar,
|
||||
hero: sizes.empty,
|
||||
}[size];
|
||||
return <UserIcon size={px} weight="regular" {...props} />;
|
||||
return <UserIcon size={phosphorSizeRem(px)} weight="regular" {...props} />;
|
||||
}
|
||||
|
||||
export {
|
||||
|
||||
@@ -7,28 +7,27 @@ import FocusTrap from 'focus-trap-react';
|
||||
import { ImageUsage } from '$plugins/custom-emoji';
|
||||
import { stopPropagation } from '$utils/keyboard';
|
||||
|
||||
export const useUsageStr = (): ((usage: ImageUsage[]) => string) => {
|
||||
const getUsageStr = (usage: ImageUsage[]): string => {
|
||||
const sticker = usage.includes(ImageUsage.Sticker);
|
||||
const emoticon = usage.includes(ImageUsage.Emoticon);
|
||||
const getUsageStr = (usage: ImageUsage[]): string => {
|
||||
const sticker = usage.includes(ImageUsage.Sticker);
|
||||
const emoticon = usage.includes(ImageUsage.Emoticon);
|
||||
|
||||
if (sticker && emoticon) return 'Both';
|
||||
if (sticker) return 'Sticker';
|
||||
if (emoticon) return 'Emoji';
|
||||
return 'Both';
|
||||
};
|
||||
return getUsageStr;
|
||||
if (sticker && emoticon) return 'Both';
|
||||
if (sticker) return 'Sticker';
|
||||
if (emoticon) return 'Emoji';
|
||||
return 'Both';
|
||||
};
|
||||
|
||||
export const useUsageStr = (): ((usage: ImageUsage[]) => string) => getUsageStr;
|
||||
|
||||
type UsageSelectorProps = {
|
||||
selected: ImageUsage[];
|
||||
onChange: (usage: ImageUsage[]) => void;
|
||||
};
|
||||
export function UsageSelector({ selected, onChange }: UsageSelectorProps) {
|
||||
const getUsageStr = useUsageStr();
|
||||
const formatUsageStr = useUsageStr();
|
||||
|
||||
const selectedUsageStr = getUsageStr(selected);
|
||||
const isSelected = (usage: ImageUsage[]) => getUsageStr(usage) === selectedUsageStr;
|
||||
const selectedUsageStr = formatUsageStr(selected);
|
||||
const isSelected = (usage: ImageUsage[]) => formatUsageStr(usage) === selectedUsageStr;
|
||||
|
||||
const allUsages: ImageUsage[][] = useMemo(
|
||||
() => [[ImageUsage.Emoticon], [ImageUsage.Sticker], [ImageUsage.Sticker, ImageUsage.Emoticon]],
|
||||
@@ -39,7 +38,7 @@ export function UsageSelector({ selected, onChange }: UsageSelectorProps) {
|
||||
<Box direction="Column" gap="100" style={{ padding: config.space.S100 }}>
|
||||
{allUsages.map((usage) => (
|
||||
<MenuItem
|
||||
key={getUsageStr(usage)}
|
||||
key={formatUsageStr(usage)}
|
||||
size="300"
|
||||
variant={isSelected(usage) ? 'SurfaceVariant' : 'Surface'}
|
||||
aria-selected={isSelected(usage)}
|
||||
@@ -47,7 +46,7 @@ export function UsageSelector({ selected, onChange }: UsageSelectorProps) {
|
||||
onClick={() => onChange(usage)}
|
||||
>
|
||||
<Box grow="Yes">
|
||||
<Text size="T300">{getUsageStr(usage)}</Text>
|
||||
<Text size="T300">{formatUsageStr(usage)}</Text>
|
||||
</Box>
|
||||
</MenuItem>
|
||||
))}
|
||||
@@ -61,7 +60,7 @@ type UsageSwitcherProps = {
|
||||
onChange: (usage: ImageUsage[]) => void;
|
||||
};
|
||||
export function UsageSwitcher({ usage, onChange, canEdit }: UsageSwitcherProps) {
|
||||
const getUsageStr = useUsageStr();
|
||||
const formatUsageStr = useUsageStr();
|
||||
|
||||
const [menuCords, setMenuCords] = useState<RectCords>();
|
||||
|
||||
@@ -82,7 +81,7 @@ export function UsageSwitcher({ usage, onChange, canEdit }: UsageSwitcherProps)
|
||||
after={canEdit && sizedIcon(CaretDown, '100')}
|
||||
onClick={canEdit ? handleSelectUsage : undefined}
|
||||
>
|
||||
<Text size="B300">{getUsageStr(usage)}</Text>
|
||||
<Text size="B300">{formatUsageStr(usage)}</Text>
|
||||
</Button>
|
||||
<PopOut
|
||||
anchor={menuCords}
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
Image,
|
||||
Minus,
|
||||
Plus,
|
||||
phosphorSizeRem,
|
||||
sizedIcon,
|
||||
} from '$components/icons/phosphor';
|
||||
import { useImageGestures } from '$hooks/useImageGestures';
|
||||
@@ -107,7 +108,10 @@ export const ImageViewer = as<'div', ImageViewerProps>(
|
||||
aria-label="Toggle Pixelation"
|
||||
title={`Turn ${isPixelated ? 'Anti-aliasing' : 'Pixelation'} on`}
|
||||
>
|
||||
<CheckerboardIcon size={20} weight={isPixelated ? 'duotone' : 'fill'} />
|
||||
<CheckerboardIcon
|
||||
size={phosphorSizeRem(20)}
|
||||
weight={isPixelated ? 'duotone' : 'fill'}
|
||||
/>
|
||||
</IconButton>
|
||||
<IconButton
|
||||
variant="Surface"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useCallback, useEffect } from 'react';
|
||||
import { useCallback, useEffect, useMemo } from 'react';
|
||||
import FocusTrap from 'focus-trap-react';
|
||||
import {
|
||||
Dialog,
|
||||
@@ -19,30 +19,76 @@ import { useMatrixClient } from '$hooks/useMatrixClient';
|
||||
import { AsyncStatus, useAsyncCallback } from '$hooks/useAsyncCallback';
|
||||
import { composerIcon, X } from '$components/icons/phosphor';
|
||||
import { stopPropagation } from '$utils/keyboard';
|
||||
import { getJoinedSpaceChildrenSummary, getRecursiveSpaceLeaveOrder } from '$utils/room';
|
||||
import { rateLimitedActions } from '$utils/matrix';
|
||||
|
||||
type LeaveSpacePromptProps = {
|
||||
roomId: string;
|
||||
onDone: () => void;
|
||||
onCancel: () => void;
|
||||
};
|
||||
|
||||
const formatJoinedContentsMessage = (roomCount: number, subspaceCount: number): string => {
|
||||
const parts: string[] = [];
|
||||
if (roomCount > 0) {
|
||||
parts.push(`${roomCount} ${roomCount === 1 ? 'room' : 'rooms'}`);
|
||||
}
|
||||
if (subspaceCount > 0) {
|
||||
parts.push(`${subspaceCount} ${subspaceCount === 1 ? 'subspace' : 'subspaces'}`);
|
||||
}
|
||||
return `You are also joined to ${parts.join(' and ')} in this space. Leaving the space alone will not remove you from them.`;
|
||||
};
|
||||
|
||||
const formatRecursiveLeaveLabel = (
|
||||
leaving: boolean,
|
||||
roomCount: number,
|
||||
subspaceCount: number
|
||||
): string => {
|
||||
if (leaving) {
|
||||
return 'Leaving space, rooms, and subspaces...';
|
||||
}
|
||||
|
||||
const parts: string[] = [];
|
||||
if (roomCount > 0) {
|
||||
parts.push('Rooms');
|
||||
}
|
||||
if (subspaceCount > 0) {
|
||||
parts.push('Subspaces');
|
||||
}
|
||||
|
||||
return `Leave Space and All ${parts.join(' & ')}`;
|
||||
};
|
||||
|
||||
export function LeaveSpacePrompt({ roomId, onDone, onCancel }: LeaveSpacePromptProps) {
|
||||
const mx = useMatrixClient();
|
||||
|
||||
const [leaveState, leaveRoom] = useAsyncCallback<undefined, MatrixError, []>(
|
||||
const { leaveOrder, roomCount, subspaceCount } = useMemo(
|
||||
() => getJoinedSpaceChildrenSummary(mx, roomId),
|
||||
[mx, roomId]
|
||||
);
|
||||
const joinedChildrenCount = leaveOrder.length;
|
||||
|
||||
const [leaveState, leaveSpace] = useAsyncCallback<undefined, MatrixError, []>(
|
||||
useCallback(async () => {
|
||||
mx.leave(roomId);
|
||||
await mx.leave(roomId);
|
||||
}, [mx, roomId])
|
||||
);
|
||||
|
||||
const handleLeave = () => {
|
||||
leaveRoom();
|
||||
};
|
||||
const [leaveAllState, leaveAll] = useAsyncCallback<undefined, MatrixError, []>(
|
||||
useCallback(async () => {
|
||||
await rateLimitedActions(getRecursiveSpaceLeaveOrder(mx, roomId), (id) => mx.leave(id));
|
||||
}, [mx, roomId])
|
||||
);
|
||||
|
||||
const leaving = leaveState.status === AsyncStatus.Loading;
|
||||
const leavingAll = leaveAllState.status === AsyncStatus.Loading;
|
||||
const isBusy = leaving || leavingAll;
|
||||
|
||||
useEffect(() => {
|
||||
if (leaveState.status === AsyncStatus.Success) {
|
||||
if (leaveState.status === AsyncStatus.Success || leaveAllState.status === AsyncStatus.Success) {
|
||||
onDone();
|
||||
}
|
||||
}, [leaveState, onDone]);
|
||||
}, [leaveState, leaveAllState, onDone]);
|
||||
|
||||
return (
|
||||
<Overlay open backdrop={<OverlayBackdrop />}>
|
||||
@@ -74,30 +120,52 @@ export function LeaveSpacePrompt({ roomId, onDone, onCancel }: LeaveSpacePromptP
|
||||
<Box style={{ padding: config.space.S400 }} direction="Column" gap="400">
|
||||
<Box direction="Column" gap="200">
|
||||
<Text priority="400">Are you sure you want to leave this space?</Text>
|
||||
{joinedChildrenCount > 0 && (
|
||||
<Text priority="300" size="T300">
|
||||
{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>
|
||||
)}
|
||||
</Box>
|
||||
<Box direction="Column" gap="200">
|
||||
<Button
|
||||
type="submit"
|
||||
variant="Critical"
|
||||
onClick={() => leaveSpace()}
|
||||
before={
|
||||
leaving ? <Spinner fill="Solid" variant="Critical" size="200" /> : undefined
|
||||
}
|
||||
aria-disabled={isBusy || leaveState.status === AsyncStatus.Success}
|
||||
>
|
||||
<Text size="B400">{leaving ? 'Leaving...' : 'Leave Space Only'}</Text>
|
||||
</Button>
|
||||
{joinedChildrenCount > 0 && (
|
||||
<Button
|
||||
variant="Critical"
|
||||
fill="Soft"
|
||||
onClick={() => leaveAll()}
|
||||
before={
|
||||
leavingAll ? (
|
||||
<Spinner fill="Solid" variant="Critical" size="200" />
|
||||
) : undefined
|
||||
}
|
||||
aria-disabled={isBusy || leaveAllState.status === AsyncStatus.Success}
|
||||
>
|
||||
<Text size="B400">
|
||||
{formatRecursiveLeaveLabel(leavingAll, roomCount, subspaceCount)}
|
||||
</Text>
|
||||
</Button>
|
||||
)}
|
||||
</Box>
|
||||
<Button
|
||||
type="submit"
|
||||
variant="Critical"
|
||||
onClick={handleLeave}
|
||||
before={
|
||||
leaveState.status === AsyncStatus.Loading ? (
|
||||
<Spinner fill="Solid" variant="Critical" size="200" />
|
||||
) : undefined
|
||||
}
|
||||
aria-disabled={
|
||||
leaveState.status === AsyncStatus.Loading ||
|
||||
leaveState.status === AsyncStatus.Success
|
||||
}
|
||||
>
|
||||
<Text size="B400">
|
||||
{leaveState.status === AsyncStatus.Loading ? 'Leaving...' : 'Leave'}
|
||||
</Text>
|
||||
</Button>
|
||||
</Box>
|
||||
</Dialog>
|
||||
</FocusTrap>
|
||||
|
||||
@@ -16,7 +16,7 @@ export const DiffCodeBlock = style([
|
||||
overflowWrap: 'anywhere',
|
||||
wordBreak: 'break-word',
|
||||
overflow: 'hidden',
|
||||
fontSize: 'inherit',
|
||||
fontSize: '1rem !important',
|
||||
lineHeight: 'inherit',
|
||||
},
|
||||
]);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import classNames from 'classnames';
|
||||
import { useCallback, useMemo, useState, type ReactNode } from 'react';
|
||||
import { Text } from 'folds';
|
||||
import { scaleSystemEmoji } from '$plugins/react-custom-html-parser';
|
||||
import { buildMessageDiffDisplay, type MessageDiffRow, type TextDiffPart } from '$utils/textDiff';
|
||||
|
||||
@@ -114,9 +113,9 @@ function DiffSkipRows({ skipIndex, lines, placement, revealed, onReveal }: DiffS
|
||||
|
||||
function InlineDiffBlock({ children }: { children: ReactNode }) {
|
||||
return (
|
||||
<Text as="pre" size="T200" className={css.DiffCodeBlock}>
|
||||
<pre className={css.DiffCodeBlock}>
|
||||
<code className={css.DiffCodeBlockInner}>{children}</code>
|
||||
</Text>
|
||||
</pre>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import type { CSSProperties, ReactNode } from 'react';
|
||||
import { useMemo } from 'react';
|
||||
import { Box, Chip, Text, toRem } from 'folds';
|
||||
import { type CSSProperties, type ReactNode, useMemo } from 'react';
|
||||
import { ArrowSquareOut, sizedIcon, Link } from '$components/icons/phosphor';
|
||||
import type { IContent, IPreviewUrlResponse, MatrixClient } from '$types/matrix-sdk';
|
||||
import { JUMBO_EMOJI_REG } from '$utils/regex';
|
||||
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 type {
|
||||
IAudioContent,
|
||||
@@ -227,7 +226,7 @@ export function MText({
|
||||
)
|
||||
)
|
||||
return true;
|
||||
if (!JUMBO_EMOJI_REG.test(trimmedBody)) return false;
|
||||
if (!isJumboEmojiText(trimmedBody)) return false;
|
||||
|
||||
if (trimmedBody.includes(':')) {
|
||||
const hasImage = customBody && /<img[^>]*>/i.test(customBody);
|
||||
@@ -338,7 +337,7 @@ export function MEmote({
|
||||
return <BrokenContent body={typeof customBody === 'string' ? customBody : undefined} />;
|
||||
}
|
||||
const trimmedBody = trimReplyFromBody(body);
|
||||
const isJumbo = JUMBO_EMOJI_REG.test(trimmedBody);
|
||||
const isJumbo = isJumboEmojiText(trimmedBody);
|
||||
|
||||
const { urls, bundleContent } = getUrlsFromContent(content, renderUrlsPreview);
|
||||
|
||||
@@ -393,7 +392,7 @@ export function MNotice({
|
||||
return <BrokenContent body={typeof customBody === 'string' ? customBody : undefined} />;
|
||||
}
|
||||
const trimmedBody = trimReplyFromBody(body);
|
||||
const isJumbo = JUMBO_EMOJI_REG.test(trimmedBody);
|
||||
const isJumbo = isJumboEmojiText(trimmedBody);
|
||||
|
||||
const { urls, bundleContent } = getUrlsFromContent(content, renderUrlsPreview);
|
||||
|
||||
@@ -419,7 +418,7 @@ export function MNotice({
|
||||
);
|
||||
}
|
||||
|
||||
type RenderImageContentProps = {
|
||||
export type RenderImageContentProps = {
|
||||
body: string;
|
||||
filename?: string;
|
||||
info?: IImageInfo & IThumbnailContent;
|
||||
|
||||
@@ -121,16 +121,24 @@ function AbbreviationTerm({ text, definition }: AbbreviationTermProps) {
|
||||
<>
|
||||
<TooltipProvider position="Top" tooltip={tooltipContent}>
|
||||
{(triggerRef) => (
|
||||
<abbr
|
||||
ref={triggerRef as React.Ref<HTMLElement>}
|
||||
<button
|
||||
type="button"
|
||||
data-no-button-motion
|
||||
ref={triggerRef as React.Ref<HTMLButtonElement>}
|
||||
onClick={handleClick}
|
||||
onKeyDown={handleKeyDown}
|
||||
role="button"
|
||||
tabIndex={0}
|
||||
style={{ textDecoration: 'underline dotted', cursor: 'help' }}
|
||||
style={{
|
||||
textDecoration: 'underline dotted',
|
||||
cursor: 'help',
|
||||
background: 'none',
|
||||
border: 'none',
|
||||
padding: 0,
|
||||
font: 'inherit',
|
||||
color: 'inherit',
|
||||
}}
|
||||
>
|
||||
{text}
|
||||
</abbr>
|
||||
</button>
|
||||
)}
|
||||
</TooltipProvider>
|
||||
{anchor && (
|
||||
|
||||
@@ -1,14 +1,29 @@
|
||||
import { JUMBO_EMOJI_REG } from '$utils/regex';
|
||||
import { isJumboEmojiText } from '$utils/emojiDetection';
|
||||
import * as css from './style.css';
|
||||
|
||||
type PowerIconProps = css.PowerIconVariants & {
|
||||
iconSrc: string;
|
||||
name?: string;
|
||||
};
|
||||
|
||||
const ALLOWED_ICON_PROTOCOLS = new Set(['http:', 'https:']);
|
||||
|
||||
function getSafeIconUrl(iconSrc: string): string | undefined {
|
||||
try {
|
||||
const parsed = new URL(iconSrc);
|
||||
return ALLOWED_ICON_PROTOCOLS.has(parsed.protocol) ? parsed.href : undefined;
|
||||
} catch {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
export function PowerIcon({ size, iconSrc, name }: PowerIconProps) {
|
||||
return JUMBO_EMOJI_REG.test(iconSrc) ? (
|
||||
<span className={css.PowerIcon({ size })}>{iconSrc}</span>
|
||||
) : (
|
||||
<img className={css.PowerIcon({ size })} src={iconSrc} alt={name} />
|
||||
);
|
||||
if (isJumboEmojiText(iconSrc, 1)) {
|
||||
return <span className={css.PowerIcon({ size })}>{iconSrc}</span>;
|
||||
}
|
||||
|
||||
const safeIconUrl = getSafeIconUrl(iconSrc);
|
||||
if (!safeIconUrl) return null;
|
||||
|
||||
return <img className={css.PowerIcon({ size })} src={safeIconUrl} alt={name} />;
|
||||
}
|
||||
@@ -34,6 +34,8 @@ export const TextViewerPre = style([
|
||||
whiteSpace: 'pre-wrap',
|
||||
overflowWrap: 'anywhere',
|
||||
wordBreak: 'break-word',
|
||||
fontSize: '1rem !important',
|
||||
lineHeight: 'inherit',
|
||||
},
|
||||
]);
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import {
|
||||
X,
|
||||
sizedIcon,
|
||||
type PhosphorIcon,
|
||||
phosphorSizeRem,
|
||||
} from '$components/icons/phosphor';
|
||||
import type { HTMLReactParserOptions } from 'html-react-parser';
|
||||
import { Play, Pause } from '@phosphor-icons/react';
|
||||
@@ -284,7 +285,11 @@ function PreviewAudio({ fileItem }: PreviewAudioProps) {
|
||||
aria-label={isPlaying ? 'Pause' : 'Play voice message'}
|
||||
aria-pressed={isPlaying}
|
||||
>
|
||||
{isPlaying ? <Pause size={20} weight="fill" /> : <Play size={20} weight="fill" />}
|
||||
{isPlaying ? (
|
||||
<Pause size={phosphorSizeRem(20)} weight="fill" />
|
||||
) : (
|
||||
<Play size={phosphorSizeRem(20)} weight="fill" />
|
||||
)}
|
||||
</IconButton>
|
||||
|
||||
<Box
|
||||
|
||||
@@ -168,7 +168,7 @@ function StateEventEdit({ type, stateKey, content, requestClose }: StateEventEdi
|
||||
<TextAreaComponent
|
||||
ref={textAreaRef}
|
||||
name="contentTextArea"
|
||||
style={{ fontFamily: 'var(--font-monospace)' }}
|
||||
style={{ fontFamily: 'var(--font-monospace)', fontSize: '1rem', lineHeight: 'inherit' }}
|
||||
onKeyDown={handleKeyDown}
|
||||
defaultValue={defaultContentStr}
|
||||
resize="None"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MouseEventHandler } from 'react';
|
||||
import type { MouseEventHandler, ComponentProps } from 'react';
|
||||
import { useMemo } from 'react';
|
||||
import type { IEventWithRoomId, Room } from '$types/matrix-sdk';
|
||||
import { JoinRule, RelationType, EventType } from '$types/matrix-sdk';
|
||||
@@ -29,6 +29,7 @@ import {
|
||||
Time,
|
||||
Username,
|
||||
UsernameBold,
|
||||
type RenderImageContentProps,
|
||||
} from '$components/message';
|
||||
import { RenderMessageContent } from '$components/RenderMessageContent';
|
||||
import { Image } from '$components/media';
|
||||
@@ -61,6 +62,104 @@ import { useSetting } from '$state/hooks/settings';
|
||||
import { settingsAtom } from '$state/settings';
|
||||
import type { ResultItem } from './useMessageSearch';
|
||||
|
||||
type SearchResultRendererContext = {
|
||||
mx: ReturnType<typeof useMatrixClient>;
|
||||
room: Room;
|
||||
mediaAutoLoad?: boolean;
|
||||
urlPreview?: boolean;
|
||||
htmlReactParserOptions: HTMLReactParserOptions;
|
||||
linkifyOpts: LinkifyOpts;
|
||||
highlightRegex: RegExp | undefined;
|
||||
};
|
||||
|
||||
function LazyImage(props: ComponentProps<typeof Image>) {
|
||||
return <Image {...props} loading="lazy" />;
|
||||
}
|
||||
|
||||
function renderSearchStickerImageContent(
|
||||
mediaAutoLoad: boolean | undefined,
|
||||
props: RenderImageContentProps
|
||||
) {
|
||||
return (
|
||||
<ImageContent
|
||||
{...props}
|
||||
autoPlay={mediaAutoLoad}
|
||||
renderImage={LazyImage}
|
||||
renderViewer={ImageViewer}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function renderSearchResultRoomMessage(
|
||||
ctx: SearchResultRendererContext,
|
||||
event: IEventWithRoomId,
|
||||
displayName: string,
|
||||
getContent: GetContentCallback
|
||||
) {
|
||||
if (event.unsigned?.redacted_because) {
|
||||
return <RedactedContent reason={event.unsigned?.redacted_because.content.reason} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<RenderMessageContent
|
||||
displayName={displayName}
|
||||
msgType={event.content.msgtype ?? ''}
|
||||
ts={event.origin_server_ts}
|
||||
getContent={getContent}
|
||||
mediaAutoLoad={ctx.mediaAutoLoad}
|
||||
urlPreview={ctx.urlPreview}
|
||||
htmlReactParserOptions={ctx.htmlReactParserOptions}
|
||||
linkifyOpts={ctx.linkifyOpts}
|
||||
highlightRegex={ctx.highlightRegex}
|
||||
outlineAttachment
|
||||
mx={ctx.mx}
|
||||
room={ctx.room}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function renderSearchResultReaction(
|
||||
ctx: SearchResultRendererContext,
|
||||
event: IEventWithRoomId,
|
||||
_displayName: string,
|
||||
getContent: GetContentCallback
|
||||
) {
|
||||
if (event.unsigned?.redacted_because) {
|
||||
return <RedactedContent reason={event.unsigned?.redacted_because.content.reason} />;
|
||||
}
|
||||
return (
|
||||
<MSticker
|
||||
content={getContent() as IImageContent}
|
||||
renderImageContent={renderSearchStickerImageContent.bind(null, ctx.mediaAutoLoad)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function renderSearchResultTombstone(_ctx: SearchResultRendererContext, event: IEventWithRoomId) {
|
||||
const { content } = event;
|
||||
return (
|
||||
<Box grow="Yes" direction="Column">
|
||||
<Text size="T400" priority="300">
|
||||
Room Tombstone. {content.body}
|
||||
</Text>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
function renderSearchResultFallback(_ctx: SearchResultRendererContext, event: IEventWithRoomId) {
|
||||
if (event.unsigned?.redacted_because) {
|
||||
return <RedactedContent reason={event.unsigned?.redacted_because.content.reason} />;
|
||||
}
|
||||
return (
|
||||
<Box grow="Yes" direction="Column">
|
||||
<Text size="T400" priority="300">
|
||||
<code className={customHtmlCss.Code}>{event.type}</code>
|
||||
{' event'}
|
||||
</Text>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
type SearchResultGroupProps = {
|
||||
room: Room;
|
||||
highlights: string[];
|
||||
@@ -153,73 +252,32 @@ export function SearchResultGroup({
|
||||
]
|
||||
);
|
||||
|
||||
const renderMatrixEvent = useMatrixEventRenderer<[IEventWithRoomId, string, GetContentCallback]>(
|
||||
{
|
||||
[EventType.RoomMessage]: (event, displayName, getContent) => {
|
||||
if (event.unsigned?.redacted_because) {
|
||||
return <RedactedContent reason={event.unsigned?.redacted_because.content.reason} />;
|
||||
}
|
||||
const rendererContext = useMemo<SearchResultRendererContext>(
|
||||
() => ({
|
||||
mx,
|
||||
room,
|
||||
mediaAutoLoad,
|
||||
urlPreview,
|
||||
htmlReactParserOptions,
|
||||
linkifyOpts,
|
||||
highlightRegex,
|
||||
}),
|
||||
[mx, room, mediaAutoLoad, urlPreview, htmlReactParserOptions, linkifyOpts, highlightRegex]
|
||||
);
|
||||
|
||||
return (
|
||||
<RenderMessageContent
|
||||
displayName={displayName}
|
||||
msgType={event.content.msgtype ?? ''}
|
||||
ts={event.origin_server_ts}
|
||||
getContent={getContent}
|
||||
mediaAutoLoad={mediaAutoLoad}
|
||||
urlPreview={urlPreview}
|
||||
htmlReactParserOptions={htmlReactParserOptions}
|
||||
linkifyOpts={linkifyOpts}
|
||||
highlightRegex={highlightRegex}
|
||||
outlineAttachment
|
||||
mx={mx}
|
||||
room={room}
|
||||
/>
|
||||
);
|
||||
},
|
||||
[EventType.Reaction]: (event, displayName, getContent) => {
|
||||
if (event.unsigned?.redacted_because) {
|
||||
return <RedactedContent reason={event.unsigned?.redacted_because.content.reason} />;
|
||||
}
|
||||
return (
|
||||
<MSticker
|
||||
content={getContent() as IImageContent}
|
||||
renderImageContent={(props) => (
|
||||
<ImageContent
|
||||
{...props}
|
||||
autoPlay={mediaAutoLoad}
|
||||
renderImage={(p) => <Image {...p} loading="lazy" />}
|
||||
renderViewer={(p) => <ImageViewer {...p} />}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
);
|
||||
},
|
||||
[EventType.RoomTombstone]: (event) => {
|
||||
const { content } = event;
|
||||
return (
|
||||
<Box grow="Yes" direction="Column">
|
||||
<Text size="T400" priority="300">
|
||||
Room Tombstone. {content.body}
|
||||
</Text>
|
||||
</Box>
|
||||
);
|
||||
},
|
||||
},
|
||||
const matrixEventHandlers = useMemo(
|
||||
() => ({
|
||||
[EventType.RoomMessage]: renderSearchResultRoomMessage.bind(null, rendererContext),
|
||||
[EventType.Reaction]: renderSearchResultReaction.bind(null, rendererContext),
|
||||
[EventType.RoomTombstone]: renderSearchResultTombstone.bind(null, rendererContext),
|
||||
}),
|
||||
[rendererContext]
|
||||
);
|
||||
|
||||
const renderMatrixEvent = useMatrixEventRenderer<[IEventWithRoomId, string, GetContentCallback]>(
|
||||
matrixEventHandlers,
|
||||
undefined,
|
||||
(event) => {
|
||||
if (event.unsigned?.redacted_because) {
|
||||
return <RedactedContent reason={event.unsigned?.redacted_because.content.reason} />;
|
||||
}
|
||||
return (
|
||||
<Box grow="Yes" direction="Column">
|
||||
<Text size="T400" priority="300">
|
||||
<code className={customHtmlCss.Code}>{event.type}</code>
|
||||
{' event'}
|
||||
</Text>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
renderSearchResultFallback.bind(null, rendererContext)
|
||||
);
|
||||
|
||||
const handleOpenClick: MouseEventHandler = (evt) => {
|
||||
|
||||
@@ -85,6 +85,7 @@ import { Presence, useUserPresence } from '$hooks/useUserPresence';
|
||||
import { AvatarPresence, PresenceBadge } from '$components/presence';
|
||||
import { RoomNavUser } from './RoomNavUser';
|
||||
import { SidebarUnreadBadge } from '$components/sidebar';
|
||||
import * as css from './styles.css';
|
||||
|
||||
/**
|
||||
* Reactively checks whether a room has unread messages.
|
||||
@@ -526,7 +527,7 @@ export function RoomNavItem({
|
||||
</UnreadBadgeCenter>
|
||||
)}
|
||||
{!optionsVisible && notificationMode !== RoomNotificationMode.Unset && (
|
||||
<span aria-label={notificationMode}>
|
||||
<span className={css.NavItemChipIcon} aria-label={notificationMode}>
|
||||
{roomNotificationModeChipIcon(notificationMode)}
|
||||
</span>
|
||||
)}
|
||||
|
||||
@@ -11,3 +11,11 @@ export const CategoryButtonIcon = style({
|
||||
lineHeight: 0,
|
||||
opacity: config.opacity.P400,
|
||||
});
|
||||
|
||||
export const NavItemChipIcon = style({
|
||||
display: 'inline-flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
lineHeight: 0,
|
||||
flexShrink: 0,
|
||||
});
|
||||
@@ -141,7 +141,7 @@ import {
|
||||
menuIcon,
|
||||
Microphone,
|
||||
PaperPlaneTilt,
|
||||
getPhosphorSize,
|
||||
getPhosphorIconSize,
|
||||
PlusCircle,
|
||||
Smiley,
|
||||
Sticker,
|
||||
@@ -340,6 +340,19 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
|
||||
useState<AutocompleteQuery<AutocompletePrefix>>();
|
||||
const [isQuickTextReact, setQuickTextReact] = useState(false);
|
||||
|
||||
const replyDraftBase = useMemo(
|
||||
() =>
|
||||
threadRootId
|
||||
? {
|
||||
userId: mx.getUserId() ?? '',
|
||||
eventId: threadRootId,
|
||||
body: '',
|
||||
relation: { rel_type: RelationType.Thread, event_id: threadRootId },
|
||||
}
|
||||
: undefined,
|
||||
[mx, threadRootId]
|
||||
);
|
||||
|
||||
const sendTypingStatus = useTypingStatusUpdater(mx, roomId, { disabled: !!threadRootId });
|
||||
|
||||
const [inputKey, setInputKey] = useState(0);
|
||||
@@ -597,16 +610,9 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
|
||||
if (contents.length > 0) {
|
||||
const replyContent =
|
||||
plainText?.length === 0 ? getReplyContent(replyDraft, room) : undefined;
|
||||
if (replyContent) contents[0]!['m.relates_to'] = replyContent;
|
||||
if (threadRootId) {
|
||||
setReplyDraft({
|
||||
userId: mx.getUserId() ?? '',
|
||||
eventId: threadRootId,
|
||||
body: '',
|
||||
relation: { rel_type: RelationType.Thread, event_id: threadRootId },
|
||||
});
|
||||
} else {
|
||||
setReplyDraft(undefined);
|
||||
if (replyContent) {
|
||||
contents[0]!['m.relates_to'] = replyContent;
|
||||
setReplyDraft(replyDraftBase);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -978,17 +984,7 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
|
||||
resetEditorHistory(editor);
|
||||
setInputKey((prev) => prev + 1);
|
||||
imagePacksUsedRef.current.clear();
|
||||
if (threadRootId) {
|
||||
// Re-seed the thread reply draft so the next message also goes to the thread.
|
||||
setReplyDraft({
|
||||
userId: mx.getUserId() ?? '',
|
||||
eventId: threadRootId,
|
||||
body: '',
|
||||
relation: { rel_type: RelationType.Thread, event_id: threadRootId },
|
||||
});
|
||||
} else {
|
||||
setReplyDraft(undefined);
|
||||
}
|
||||
setReplyDraft(replyDraftBase);
|
||||
sendTypingStatus(false);
|
||||
};
|
||||
if (scheduledTime) {
|
||||
@@ -1115,6 +1111,7 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
|
||||
setEditingScheduledDelayId,
|
||||
setScheduledTime,
|
||||
setServerMaxDelayMs,
|
||||
replyDraftBase,
|
||||
]);
|
||||
|
||||
const handleKeyDown: KeyboardEventHandler = useCallback(
|
||||
@@ -1291,16 +1288,7 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
|
||||
|
||||
if (replyDraft) {
|
||||
content['m.relates_to'] = getReplyContent(replyDraft, room);
|
||||
if (threadRootId) {
|
||||
setReplyDraft({
|
||||
userId: mx.getUserId() ?? '',
|
||||
eventId: threadRootId,
|
||||
body: '',
|
||||
relation: { rel_type: RelationType.Thread, event_id: threadRootId },
|
||||
});
|
||||
} else {
|
||||
setReplyDraft(undefined);
|
||||
}
|
||||
setReplyDraft(replyDraftBase);
|
||||
}
|
||||
mx.sendEvent(roomId, EventType.Sticker, content);
|
||||
};
|
||||
@@ -1671,7 +1659,7 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
|
||||
>
|
||||
{showAudioRecorder ? (
|
||||
<Stop
|
||||
size={getPhosphorSize().toolbar}
|
||||
size={getPhosphorIconSize('toolbar')}
|
||||
weight="fill"
|
||||
style={{ color: color.Critical.Main }}
|
||||
/>
|
||||
@@ -1876,7 +1864,7 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
|
||||
mx={mx}
|
||||
room={room}
|
||||
replyDraft={replyDraft}
|
||||
clearReplyDraft={() => setReplyDraft(undefined)}
|
||||
clearReplyDraft={() => setReplyDraft(replyDraftBase)}
|
||||
/>
|
||||
)}
|
||||
{showLocationPicker && (
|
||||
@@ -1885,7 +1873,7 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
|
||||
mx={mx}
|
||||
room={room}
|
||||
replyDraft={replyDraft}
|
||||
clearReplyDraft={() => setReplyDraft(undefined)}
|
||||
clearReplyDraft={() => setReplyDraft(replyDraftBase)}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -25,10 +25,11 @@ import {
|
||||
renderMatrixMention,
|
||||
} from '$plugins/react-custom-html-parser';
|
||||
import {
|
||||
getEditedEvent,
|
||||
extractReplyDraftBody,
|
||||
getMemberDisplayName,
|
||||
isThreadRelationEvent,
|
||||
reactionOrEditEvent,
|
||||
resolveReplyDraftTarget,
|
||||
unwrapRelationJumpTarget,
|
||||
} from '$utils/room';
|
||||
import { getMxIdLocalPart, toggleReaction } from '$utils/matrix';
|
||||
@@ -67,7 +68,6 @@ import { RoomViewFollowing, RoomViewFollowingPlaceholder } from './RoomViewFollo
|
||||
import * as css from './ThreadDrawer.css';
|
||||
import { SidebarResizer } from '$pages/client/sidebar/SidebarResizer';
|
||||
import { mobileOrTablet } from '$utils/user-agent';
|
||||
import { M_TEXT } from 'matrix-js-sdk';
|
||||
|
||||
/**
|
||||
* Resolve the list of reply events to show in the thread drawer.
|
||||
@@ -569,28 +569,25 @@ export function ThreadDrawer({ room, threadRootId, onClose, overlay }: ThreadDra
|
||||
});
|
||||
return;
|
||||
}
|
||||
const replyEvt = room.findEventById(replyId);
|
||||
if (!replyEvt) return;
|
||||
const editedReply = getEditedEvent(replyId, replyEvt, room.getUnfilteredTimelineSet());
|
||||
const content = editedReply?.getContent()['m.new_content'] ?? replyEvt.getContent();
|
||||
const { body, formatted_body: formattedBody } = content;
|
||||
const msc1767body = content[M_TEXT.name];
|
||||
const resolved = resolveReplyDraftTarget(room, replyId);
|
||||
if (!resolved) return;
|
||||
const { eventId: draftEventId, replyEvt } = resolved;
|
||||
const { body, formattedBody } = extractReplyDraftBody(
|
||||
replyEvt,
|
||||
room.getUnfilteredTimelineSet()
|
||||
);
|
||||
const senderId = replyEvt.getSender();
|
||||
if (senderId) {
|
||||
const draft: IReplyDraft = {
|
||||
userId: senderId,
|
||||
eventId: replyId,
|
||||
body:
|
||||
(body as string) ??
|
||||
(msc1767body as string) ??
|
||||
(msc1767body as { body: string }).body ??
|
||||
'',
|
||||
eventId: draftEventId,
|
||||
body,
|
||||
formattedBody,
|
||||
relation: { rel_type: RelationType.Thread, event_id: threadRootId },
|
||||
};
|
||||
// Only toggle off if we're actively replying to this event (non-empty body distinguishes
|
||||
// a real reply draft from the seeded base-thread draft, which has body: '').
|
||||
if (activeReplyId === replyId && replyDraft?.body) {
|
||||
if (activeReplyId === draftEventId && replyDraft?.body) {
|
||||
// Toggle off — reset to base thread draft
|
||||
setReplyDraft({
|
||||
userId: mx.getUserId() ?? '',
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MouseEventHandler, ReactNode } from 'react';
|
||||
import type { MouseEventHandler, ReactNode, ComponentProps } from 'react';
|
||||
import { forwardRef, useCallback, useMemo, useRef } from 'react';
|
||||
import type { MatrixEvent, Room, RoomPinnedEventsEventContent } from '$types/matrix-sdk';
|
||||
import type { IImageContent } from '$types/matrix/common';
|
||||
@@ -38,6 +38,7 @@ import {
|
||||
Time,
|
||||
Username,
|
||||
UsernameBold,
|
||||
type RenderImageContentProps,
|
||||
} from '$components/message';
|
||||
import { UserAvatar } from '$components/user-avatar';
|
||||
import {
|
||||
@@ -290,6 +291,223 @@ function PinnedMessage(props: PinnedMessageProps) {
|
||||
);
|
||||
}
|
||||
|
||||
type PinMenuRendererContext = {
|
||||
mx: ReturnType<typeof useMatrixClient>;
|
||||
room: Room;
|
||||
mediaAutoLoad: boolean;
|
||||
urlPreview: boolean;
|
||||
htmlReactParserOptions: HTMLReactParserOptions;
|
||||
linkifyOpts: LinkifyOpts;
|
||||
};
|
||||
|
||||
function PinMenuLazyImage(props: ComponentProps<typeof Image>) {
|
||||
return <Image {...props} loading="lazy" />;
|
||||
}
|
||||
|
||||
function renderPinMenuStickerImageContent(
|
||||
mediaAutoLoad: boolean | undefined,
|
||||
props: RenderImageContentProps
|
||||
) {
|
||||
return (
|
||||
<ImageContent
|
||||
{...props}
|
||||
autoPlay={mediaAutoLoad}
|
||||
renderImage={PinMenuLazyImage}
|
||||
renderViewer={ImageViewer}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function renderPinMenuRoomMessage(
|
||||
ctx: PinMenuRendererContext,
|
||||
event: MatrixEvent,
|
||||
displayName: string,
|
||||
getContent: GetContentCallback
|
||||
) {
|
||||
if (event.isRedacted()) {
|
||||
const unsigned = event.getUnsigned();
|
||||
const redactionContent = unsigned.redacted_because?.content as { reason?: string } | undefined;
|
||||
return <RedactedContent reason={redactionContent?.reason} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<RenderMessageContent
|
||||
displayName={displayName}
|
||||
msgType={event.getContent().msgtype ?? ''}
|
||||
ts={event.getTs()}
|
||||
getContent={getContent}
|
||||
edited={!!event.replacingEvent()}
|
||||
mediaAutoLoad={ctx.mediaAutoLoad}
|
||||
urlPreview={ctx.urlPreview}
|
||||
htmlReactParserOptions={ctx.htmlReactParserOptions}
|
||||
linkifyOpts={ctx.linkifyOpts}
|
||||
outlineAttachment
|
||||
mEvent={event}
|
||||
mx={ctx.mx}
|
||||
room={ctx.room}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function renderPinMenuEncryptedDecrypted(
|
||||
ctx: PinMenuRendererContext,
|
||||
event: MatrixEvent,
|
||||
displayName: string,
|
||||
mEvent: MatrixEvent,
|
||||
evtTimeline: NonNullable<ReturnType<Room['getTimelineForEvent']>>
|
||||
) {
|
||||
const eventId = event.getId()!;
|
||||
const eventType = mEvent.getType();
|
||||
const stickerEventType: string = EventType.Sticker;
|
||||
const roomMessageEventType: string = EventType.RoomMessage;
|
||||
const encryptedMessageEventType: string = EventType.RoomMessageEncrypted;
|
||||
|
||||
if (mEvent.isRedacted()) return <RedactedContent />;
|
||||
if (eventType === stickerEventType) {
|
||||
return (
|
||||
<MSticker
|
||||
content={mEvent.getContent()}
|
||||
renderImageContent={renderPinMenuStickerImageContent.bind(null, ctx.mediaAutoLoad)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
if (eventType === roomMessageEventType) {
|
||||
const editedEvent = getEditedEvent(eventId, mEvent, evtTimeline.getTimelineSet());
|
||||
const getContent = (() => {
|
||||
const eventContent = mEvent.getContent();
|
||||
const editContent = editedEvent?.getContent();
|
||||
return (editContent?.['m.new_content'] ?? eventContent) as Record<string, unknown>;
|
||||
}) as GetContentCallback;
|
||||
|
||||
return (
|
||||
<RenderMessageContent
|
||||
displayName={displayName}
|
||||
msgType={mEvent.getContent().msgtype ?? ''}
|
||||
ts={mEvent.getTs()}
|
||||
edited={!!editedEvent || !!mEvent.replacingEvent()}
|
||||
getContent={getContent}
|
||||
mediaAutoLoad={ctx.mediaAutoLoad}
|
||||
urlPreview={ctx.urlPreview}
|
||||
htmlReactParserOptions={ctx.htmlReactParserOptions}
|
||||
linkifyOpts={ctx.linkifyOpts}
|
||||
mx={ctx.mx}
|
||||
room={ctx.room}
|
||||
mEvent={event}
|
||||
/>
|
||||
);
|
||||
}
|
||||
if (eventType === encryptedMessageEventType) {
|
||||
return (
|
||||
<Text>
|
||||
<MessageNotDecryptedContent />
|
||||
</Text>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<Text>
|
||||
<MessageUnsupportedContent />
|
||||
</Text>
|
||||
);
|
||||
}
|
||||
|
||||
function renderPinMenuEncrypted(
|
||||
ctx: PinMenuRendererContext,
|
||||
event: MatrixEvent,
|
||||
displayName: string
|
||||
) {
|
||||
const eventId = event.getId()!;
|
||||
const evtTimeline = ctx.room.getTimelineForEvent(eventId);
|
||||
const mEvent = evtTimeline?.getEvents().find((e: MatrixEvent) => e.getId() === eventId);
|
||||
|
||||
if (!mEvent || !evtTimeline) {
|
||||
return (
|
||||
<Box grow="Yes" direction="Column">
|
||||
<Text size="T400" priority="300">
|
||||
<code className={customHtmlCss.Code}>{event.getType()}</code>
|
||||
{' event'}
|
||||
</Text>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<EncryptedContent mEvent={mEvent}>
|
||||
{renderPinMenuEncryptedDecrypted.bind(null, ctx, event, displayName, mEvent, evtTimeline)}
|
||||
</EncryptedContent>
|
||||
);
|
||||
}
|
||||
|
||||
function renderPinMenuSticker(
|
||||
ctx: PinMenuRendererContext,
|
||||
event: MatrixEvent,
|
||||
_displayName: string,
|
||||
getContent: GetContentCallback
|
||||
) {
|
||||
if (event.isRedacted()) {
|
||||
const unsigned = event.getUnsigned();
|
||||
const redactionContent = unsigned.redacted_because?.content as
|
||||
| Record<string, unknown>
|
||||
| undefined;
|
||||
|
||||
return <RedactedContent reason={redactionContent?.reason as string | undefined} />;
|
||||
}
|
||||
return (
|
||||
<MSticker
|
||||
content={getContent() as IImageContent}
|
||||
renderImageContent={renderPinMenuStickerImageContent.bind(null, ctx.mediaAutoLoad)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function renderPinMenuPollStart(
|
||||
ctx: PinMenuRendererContext,
|
||||
event: MatrixEvent,
|
||||
displayName: string,
|
||||
getContent: GetContentCallback
|
||||
) {
|
||||
if (event.isRedacted()) {
|
||||
const unsigned = event.getUnsigned();
|
||||
const redactionContent = unsigned.redacted_because?.content as { reason?: string } | undefined;
|
||||
return <RedactedContent reason={redactionContent?.reason} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<RenderMessageContent
|
||||
displayName={displayName}
|
||||
msgType={event.getContent().msgtype ?? ''}
|
||||
ts={event.getTs()}
|
||||
getContent={getContent}
|
||||
edited={!!event.replacingEvent()}
|
||||
mediaAutoLoad={ctx.mediaAutoLoad}
|
||||
urlPreview={ctx.urlPreview}
|
||||
htmlReactParserOptions={ctx.htmlReactParserOptions}
|
||||
linkifyOpts={ctx.linkifyOpts}
|
||||
outlineAttachment
|
||||
mEvent={event}
|
||||
mx={ctx.mx}
|
||||
room={ctx.room}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function renderPinMenuFallback(_ctx: PinMenuRendererContext, event: MatrixEvent) {
|
||||
if (event.isRedacted()) {
|
||||
const unsigned = event.getUnsigned();
|
||||
const redactionContent = unsigned.redacted_because?.content as
|
||||
| Record<string, unknown>
|
||||
| undefined;
|
||||
return <RedactedContent reason={redactionContent?.reason as string | undefined} />;
|
||||
}
|
||||
return (
|
||||
<Box grow="Yes" direction="Column">
|
||||
<Text size="T400" priority="300">
|
||||
<code className={customHtmlCss.Code}>{event.getType()}</code>
|
||||
{' event'}
|
||||
</Text>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
type RoomPinMenuProps = {
|
||||
room: Room;
|
||||
requestClose: () => void;
|
||||
@@ -392,186 +610,32 @@ export const RoomPinMenu = forwardRef<HTMLDivElement, RoomPinMenuProps>(
|
||||
]
|
||||
);
|
||||
|
||||
const rendererContext = useMemo<PinMenuRendererContext>(
|
||||
() => ({
|
||||
mx,
|
||||
room,
|
||||
mediaAutoLoad,
|
||||
urlPreview,
|
||||
htmlReactParserOptions,
|
||||
linkifyOpts,
|
||||
}),
|
||||
[mx, room, mediaAutoLoad, urlPreview, htmlReactParserOptions, linkifyOpts]
|
||||
);
|
||||
|
||||
const matrixEventHandlers = useMemo(
|
||||
() => ({
|
||||
[EventType.RoomMessage]: renderPinMenuRoomMessage.bind(null, rendererContext),
|
||||
[EventType.RoomMessageEncrypted]: renderPinMenuEncrypted.bind(null, rendererContext),
|
||||
[EventType.Sticker]: renderPinMenuSticker.bind(null, rendererContext),
|
||||
[M_POLL_START.name]: renderPinMenuPollStart.bind(null, rendererContext),
|
||||
}),
|
||||
[rendererContext]
|
||||
);
|
||||
|
||||
const renderMatrixEvent = useMatrixEventRenderer<[MatrixEvent, string, GetContentCallback]>(
|
||||
{
|
||||
[EventType.RoomMessage]: (event, displayName, getContent) => {
|
||||
if (event.isRedacted()) {
|
||||
const unsigned = event.getUnsigned();
|
||||
const redactionContent = unsigned.redacted_because?.content as
|
||||
| { reason?: string }
|
||||
| undefined;
|
||||
return <RedactedContent reason={redactionContent?.reason} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<RenderMessageContent
|
||||
displayName={displayName}
|
||||
msgType={event.getContent().msgtype ?? ''}
|
||||
ts={event.getTs()}
|
||||
getContent={getContent}
|
||||
edited={!!event.replacingEvent()}
|
||||
mediaAutoLoad={mediaAutoLoad}
|
||||
urlPreview={urlPreview}
|
||||
htmlReactParserOptions={htmlReactParserOptions}
|
||||
linkifyOpts={linkifyOpts}
|
||||
outlineAttachment
|
||||
mEvent={event}
|
||||
mx={mx}
|
||||
room={room}
|
||||
/>
|
||||
);
|
||||
},
|
||||
[EventType.RoomMessageEncrypted]: (event, displayName) => {
|
||||
const eventId = event.getId()!;
|
||||
const evtTimeline = room.getTimelineForEvent(eventId);
|
||||
|
||||
const mEvent = evtTimeline?.getEvents().find((e: MatrixEvent) => e.getId() === eventId);
|
||||
|
||||
if (!mEvent || !evtTimeline) {
|
||||
return (
|
||||
<Box grow="Yes" direction="Column">
|
||||
<Text size="T400" priority="300">
|
||||
<code className={customHtmlCss.Code}>{event.getType()}</code>
|
||||
{' event'}
|
||||
</Text>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<EncryptedContent mEvent={mEvent}>
|
||||
{() => {
|
||||
const eventType = mEvent.getType();
|
||||
const stickerEventType: string = EventType.Sticker;
|
||||
const roomMessageEventType: string = EventType.RoomMessage;
|
||||
const encryptedMessageEventType: string = EventType.RoomMessageEncrypted;
|
||||
if (mEvent.isRedacted()) return <RedactedContent />;
|
||||
if (eventType === stickerEventType)
|
||||
return (
|
||||
<MSticker
|
||||
content={mEvent.getContent()}
|
||||
renderImageContent={(props) => (
|
||||
<ImageContent
|
||||
{...props}
|
||||
autoPlay={mediaAutoLoad}
|
||||
renderImage={(p) => <Image {...p} loading="lazy" />}
|
||||
renderViewer={(p) => <ImageViewer {...p} />}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
);
|
||||
if (eventType === roomMessageEventType) {
|
||||
const editedEvent = getEditedEvent(eventId, mEvent, evtTimeline.getTimelineSet());
|
||||
const getContent = (() => {
|
||||
const eventContent = mEvent.getContent();
|
||||
const editContent = editedEvent?.getContent();
|
||||
return (editContent?.['m.new_content'] ?? eventContent) as Record<
|
||||
string,
|
||||
unknown
|
||||
>;
|
||||
}) as GetContentCallback;
|
||||
|
||||
return (
|
||||
<RenderMessageContent
|
||||
displayName={displayName}
|
||||
msgType={mEvent.getContent().msgtype ?? ''}
|
||||
ts={mEvent.getTs()}
|
||||
edited={!!editedEvent || !!mEvent.replacingEvent()}
|
||||
getContent={getContent}
|
||||
mediaAutoLoad={mediaAutoLoad}
|
||||
urlPreview={urlPreview}
|
||||
htmlReactParserOptions={htmlReactParserOptions}
|
||||
linkifyOpts={linkifyOpts}
|
||||
mx={mx}
|
||||
room={room}
|
||||
mEvent={event}
|
||||
/>
|
||||
);
|
||||
}
|
||||
if (eventType === encryptedMessageEventType)
|
||||
return (
|
||||
<Text>
|
||||
<MessageNotDecryptedContent />
|
||||
</Text>
|
||||
);
|
||||
return (
|
||||
<Text>
|
||||
<MessageUnsupportedContent />
|
||||
</Text>
|
||||
);
|
||||
}}
|
||||
</EncryptedContent>
|
||||
);
|
||||
},
|
||||
[EventType.Sticker]: (event, _displayName, getContent) => {
|
||||
if (event.isRedacted()) {
|
||||
const unsigned = event.getUnsigned();
|
||||
const redactionContent = unsigned.redacted_because?.content as
|
||||
| Record<string, unknown>
|
||||
| undefined;
|
||||
|
||||
return <RedactedContent reason={redactionContent?.reason as string | undefined} />;
|
||||
}
|
||||
return (
|
||||
<MSticker
|
||||
content={getContent() as IImageContent}
|
||||
renderImageContent={(props) => (
|
||||
<ImageContent
|
||||
{...props}
|
||||
autoPlay={mediaAutoLoad}
|
||||
renderImage={(p) => <Image {...p} loading="lazy" />}
|
||||
renderViewer={(p) => <ImageViewer {...p} />}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
);
|
||||
},
|
||||
[M_POLL_START.name]: (event, displayName, getContent) => {
|
||||
if (event.isRedacted()) {
|
||||
const unsigned = event.getUnsigned();
|
||||
const redactionContent = unsigned.redacted_because?.content as
|
||||
| { reason?: string }
|
||||
| undefined;
|
||||
return <RedactedContent reason={redactionContent?.reason} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<RenderMessageContent
|
||||
displayName={displayName}
|
||||
msgType={event.getContent().msgtype ?? ''}
|
||||
ts={event.getTs()}
|
||||
getContent={getContent}
|
||||
edited={!!event.replacingEvent()}
|
||||
mediaAutoLoad={mediaAutoLoad}
|
||||
urlPreview={urlPreview}
|
||||
htmlReactParserOptions={htmlReactParserOptions}
|
||||
linkifyOpts={linkifyOpts}
|
||||
outlineAttachment
|
||||
mEvent={event}
|
||||
mx={mx}
|
||||
room={room}
|
||||
/>
|
||||
);
|
||||
},
|
||||
},
|
||||
matrixEventHandlers,
|
||||
undefined,
|
||||
(event) => {
|
||||
if (event.isRedacted()) {
|
||||
const unsigned = event.getUnsigned();
|
||||
const redactionContent = unsigned.redacted_because?.content as
|
||||
| Record<string, unknown>
|
||||
| undefined;
|
||||
return <RedactedContent reason={redactionContent?.reason as string | undefined} />;
|
||||
}
|
||||
return (
|
||||
<Box grow="Yes" direction="Column">
|
||||
<Text size="T400" priority="300">
|
||||
<code className={customHtmlCss.Code}>{event.getType()}</code>
|
||||
{' event'}
|
||||
</Text>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
renderPinMenuFallback.bind(null, rendererContext)
|
||||
);
|
||||
|
||||
const handleOpen = (roomId: string, eventId: string) => {
|
||||
|
||||
@@ -209,6 +209,19 @@ function CodeBlockThemeSettings() {
|
||||
);
|
||||
}
|
||||
|
||||
const onNumberInputKeyDown =
|
||||
(reset: () => void): KeyboardEventHandler<HTMLInputElement> =>
|
||||
(evt) => {
|
||||
if (isKeyHotkey('escape', evt)) {
|
||||
evt.stopPropagation();
|
||||
reset();
|
||||
(evt.target as HTMLInputElement).blur();
|
||||
}
|
||||
if (isKeyHotkey('enter', evt)) {
|
||||
(evt.target as HTMLInputElement).blur();
|
||||
}
|
||||
};
|
||||
|
||||
function ThemeVisualPreferences() {
|
||||
const [saturation, setSaturation] = useSetting(settingsAtom, 'saturationLevel');
|
||||
const [underlineLinks, setUnderlineLinks] = useSetting(settingsAtom, 'underlineLinks');
|
||||
@@ -269,19 +282,6 @@ function ThemeVisualPreferences() {
|
||||
if (!Number.isNaN(parsed)) setLinkPreviewImageMaxHeight(clampIncomingInlineImageHeight(parsed));
|
||||
};
|
||||
|
||||
const onNumberInputKeyDown =
|
||||
(reset: () => void): KeyboardEventHandler<HTMLInputElement> =>
|
||||
(evt) => {
|
||||
if (isKeyHotkey('escape', evt)) {
|
||||
evt.stopPropagation();
|
||||
reset();
|
||||
(evt.target as HTMLInputElement).blur();
|
||||
}
|
||||
if (isKeyHotkey('enter', evt)) {
|
||||
(evt.target as HTMLInputElement).blur();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Box direction="Column" gap="100">
|
||||
<Text size="L400">Display</Text>
|
||||
|
||||
@@ -19,6 +19,17 @@ const ALL_CATEGORIES: LogCategory[] = [
|
||||
'general',
|
||||
];
|
||||
|
||||
const handleExportLogs = () => {
|
||||
const data = getDebugLogger().exportLogs();
|
||||
const blob = new Blob([data], { type: 'application/json' });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = `sable-debug-logs-${Date.now()}.json`;
|
||||
a.click();
|
||||
URL.revokeObjectURL(url);
|
||||
};
|
||||
|
||||
export function SentrySettings() {
|
||||
const [categoryEnabled, setCategoryEnabled] = useState<Record<LogCategory, boolean>>(() => {
|
||||
const logger = getDebugLogger();
|
||||
@@ -40,17 +51,6 @@ export function SentrySettings() {
|
||||
setCategoryEnabled((prev) => ({ ...prev, [category]: enabled }));
|
||||
};
|
||||
|
||||
const handleExportLogs = () => {
|
||||
const data = getDebugLogger().exportLogs();
|
||||
const blob = new Blob([data], { type: 'application/json' });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = `sable-debug-logs-${Date.now()}.json`;
|
||||
a.click();
|
||||
URL.revokeObjectURL(url);
|
||||
};
|
||||
|
||||
const isSentryConfigured = Boolean(import.meta.env.VITE_SENTRY_DSN);
|
||||
const sentryEnabled = localStorage.getItem('sable_sentry_enabled') === 'true';
|
||||
const environment = import.meta.env.VITE_SENTRY_ENVIRONMENT || import.meta.env.MODE;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useCallback, useState } from 'react';
|
||||
import { Box, Button, config, Menu, Spinner, Text } from 'folds';
|
||||
import type { AuthDict, IMyDevice, MatrixError } from '$types/matrix-sdk';
|
||||
import type { AuthDict, IAuthData, IMyDevice, MatrixError, UIAFlow } from '$types/matrix-sdk';
|
||||
import { SequenceCard } from '$components/sequence-card';
|
||||
import { ActionUIA, ActionUIAFlowsLoader } from '$components/ActionUIA';
|
||||
import type { AsyncState } from '$hooks/useAsyncCallback';
|
||||
@@ -17,6 +17,37 @@ import { SequenceCardStyle } from '$features/settings/styles.css';
|
||||
import { VerifyOtherDeviceTile } from './Verification';
|
||||
import { DeviceDeleteBtn, DeviceTile } from './DeviceTile';
|
||||
|
||||
function renderUnsupportedUIAFlow() {
|
||||
return (
|
||||
<Text size="T200">
|
||||
Authentication steps to perform this action are not supported by client.
|
||||
</Text>
|
||||
);
|
||||
}
|
||||
|
||||
type DeleteDevicesUIAProps = {
|
||||
authData: IAuthData;
|
||||
ongoingFlow: UIAFlow;
|
||||
deleteDevices: (authDict?: AuthDict) => void;
|
||||
onCancel: () => void;
|
||||
};
|
||||
|
||||
function DeleteDevicesUIA({
|
||||
authData,
|
||||
ongoingFlow,
|
||||
deleteDevices,
|
||||
onCancel,
|
||||
}: DeleteDevicesUIAProps) {
|
||||
return (
|
||||
<ActionUIA
|
||||
authData={authData}
|
||||
ongoingFlow={ongoingFlow}
|
||||
action={deleteDevices}
|
||||
onCancel={onCancel}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
type OtherDevicesProps = {
|
||||
devices: IMyDevice[];
|
||||
refreshDeviceList: () => Promise<void>;
|
||||
@@ -102,6 +133,19 @@ export function OtherDevices({ devices, refreshDeviceList, showVerification }: O
|
||||
setDeleteState({ status: AsyncStatus.Idle });
|
||||
}, []);
|
||||
|
||||
const renderDeleteDevicesUIA = useCallback(
|
||||
(ongoingFlow: UIAFlow) =>
|
||||
authData ? (
|
||||
<DeleteDevicesUIA
|
||||
authData={authData}
|
||||
ongoingFlow={ongoingFlow}
|
||||
deleteDevices={deleteDevices}
|
||||
onCancel={handleCancelAuth}
|
||||
/>
|
||||
) : null,
|
||||
[authData, deleteDevices, handleCancelAuth]
|
||||
);
|
||||
|
||||
return devices.length > 0 ? (
|
||||
<>
|
||||
<Box direction="Column" gap="100">
|
||||
@@ -208,22 +252,8 @@ export function OtherDevices({ devices, refreshDeviceList, showVerification }: O
|
||||
</Text>
|
||||
)}
|
||||
{authData && (
|
||||
<ActionUIAFlowsLoader
|
||||
authData={authData}
|
||||
unsupported={() => (
|
||||
<Text size="T200">
|
||||
Authentication steps to perform this action are not supported by client.
|
||||
</Text>
|
||||
)}
|
||||
>
|
||||
{(ongoingFlow) => (
|
||||
<ActionUIA
|
||||
authData={authData}
|
||||
ongoingFlow={ongoingFlow}
|
||||
action={deleteDevices}
|
||||
onCancel={handleCancelAuth}
|
||||
/>
|
||||
)}
|
||||
<ActionUIAFlowsLoader authData={authData} unsupported={renderUnsupportedUIAFlow}>
|
||||
{renderDeleteDevicesUIA}
|
||||
</ActionUIAFlowsLoader>
|
||||
)}
|
||||
</Box>
|
||||
|
||||
@@ -292,13 +292,14 @@ type PresetDateFormatProps = {
|
||||
value: string;
|
||||
onChange: (format: string) => void;
|
||||
};
|
||||
|
||||
const getDisplayDate = (format: string): string =>
|
||||
format === '' ? 'Custom' : dayjs().format(format);
|
||||
|
||||
function PresetDateFormat({ value, onChange }: Readonly<PresetDateFormatProps>) {
|
||||
const [menuCords, setMenuCords] = useState<RectCords>();
|
||||
const dateFormatItems = useDateFormatItems();
|
||||
|
||||
const getDisplayDate = (format: string): string =>
|
||||
format === '' ? 'Custom' : dayjs().format(format);
|
||||
|
||||
const handleMenu: MouseEventHandler<HTMLButtonElement> = (evt) => {
|
||||
setMenuCords(evt.currentTarget.getBoundingClientRect());
|
||||
};
|
||||
|
||||
@@ -175,6 +175,10 @@ export function SystemNotification() {
|
||||
settingsAtom,
|
||||
'isNotificationSounds'
|
||||
);
|
||||
const [backgroundNotificationSounds, setBackgroundNotificationSounds] = useSetting(
|
||||
settingsAtom,
|
||||
'backgroundNotificationSounds'
|
||||
);
|
||||
const [showMessageContent, setShowMessageContent] = useSetting(
|
||||
settingsAtom,
|
||||
'showMessageContentInNotifications'
|
||||
@@ -281,6 +285,25 @@ export function SystemNotification() {
|
||||
after={<Switch value={isNotificationSounds} onChange={setIsNotificationSounds} />}
|
||||
/>
|
||||
</SequenceCard>
|
||||
<SequenceCard
|
||||
className={SequenceCardStyle}
|
||||
variant="SurfaceVariant"
|
||||
direction="Column"
|
||||
gap="400"
|
||||
>
|
||||
<SettingTile
|
||||
title="Background Tab Sound"
|
||||
focusId="background-notification-sound"
|
||||
description="Play the notification sound when this browser tab is in the background."
|
||||
after={
|
||||
<Switch
|
||||
value={backgroundNotificationSounds}
|
||||
onChange={setBackgroundNotificationSounds}
|
||||
disabled={!isNotificationSounds}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
</SequenceCard>
|
||||
<SequenceCard
|
||||
className={SequenceCardStyle}
|
||||
variant="SurfaceVariant"
|
||||
|
||||
@@ -157,6 +157,7 @@ const settingsLinkFocusIdsBySection: Record<SettingsSectionId, readonly string[]
|
||||
'favicon-dot-mentions-only',
|
||||
'highlight-mentions',
|
||||
'in-app-notification-sound',
|
||||
'background-notification-sound',
|
||||
'in-app-notifications',
|
||||
'mention-room',
|
||||
'mention-user-id',
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
import type { MouseEventHandler } from 'react';
|
||||
import { useCallback } from 'react';
|
||||
import type { MatrixClient, Room, MatrixEvent, IContent } from '$types/matrix-sdk';
|
||||
import type { MatrixClient, Room, MatrixEvent } from '$types/matrix-sdk';
|
||||
import type { UserProfile } from '$hooks/useUserProfile';
|
||||
import { EventStatus } from '$types/matrix-sdk';
|
||||
import type { Editor } from 'slate';
|
||||
import { ReactEditor } from 'slate-react';
|
||||
|
||||
import { getMxIdLocalPart, toggleReaction } from '$utils/matrix';
|
||||
import { getMemberDisplayName, getEditedEvent } from '$utils/room';
|
||||
import { extractReplyDraftBody, getMemberDisplayName, resolveReplyDraftTarget } from '$utils/room';
|
||||
import { createMentionElement, moveCursor } from '$components/editor';
|
||||
import * as prefix from '$unstable/prefixes';
|
||||
import { M_TEXT } from 'matrix-js-sdk';
|
||||
|
||||
export interface UseTimelineActionsOptions {
|
||||
room: Room;
|
||||
@@ -127,28 +126,21 @@ export function useTimelineActions({
|
||||
|
||||
const triggerReply = useCallback(
|
||||
(replyId: string, startThread = false) => {
|
||||
if (activeReplyId === replyId) {
|
||||
const resolved = resolveReplyDraftTarget(room, replyId);
|
||||
if (!resolved) return;
|
||||
|
||||
const { eventId: draftEventId, replyEvt } = resolved;
|
||||
|
||||
if (activeReplyId === draftEventId) {
|
||||
setReplyDraft(undefined);
|
||||
return;
|
||||
}
|
||||
|
||||
const replyEvt = room.findEventById(replyId);
|
||||
if (!replyEvt) return;
|
||||
|
||||
const editedReply = getEditedEvent(replyId, replyEvt, room.getUnfilteredTimelineSet());
|
||||
|
||||
let editedNewContent: unknown;
|
||||
|
||||
if (editedReply) {
|
||||
editedNewContent = editedReply.getContent()['m.new_content'];
|
||||
}
|
||||
|
||||
const content: IContent = (editedNewContent ?? replyEvt.getContent()) as IContent;
|
||||
const { body, formatted_body: formattedBody } = content;
|
||||
const msc1767body = content[M_TEXT.name];
|
||||
const timelineSet = room.getUnfilteredTimelineSet();
|
||||
const { body, formattedBody } = extractReplyDraftBody(replyEvt, timelineSet);
|
||||
|
||||
const { 'm.relates_to': relation } = startThread
|
||||
? { 'm.relates_to': { rel_type: 'm.thread', event_id: replyId } }
|
||||
? { 'm.relates_to': { rel_type: 'm.thread', event_id: draftEventId } }
|
||||
: replyEvt.getWireContent();
|
||||
|
||||
const senderId = replyEvt.getSender();
|
||||
@@ -156,13 +148,9 @@ export function useTimelineActions({
|
||||
if (senderId) {
|
||||
setReplyDraft({
|
||||
userId: senderId,
|
||||
eventId: replyId,
|
||||
body:
|
||||
(body as string) ??
|
||||
(msc1767body as string) ??
|
||||
(msc1767body as { body: string }).body ??
|
||||
'',
|
||||
formattedBody: typeof formattedBody === 'string' ? formattedBody : '',
|
||||
eventId: draftEventId,
|
||||
body,
|
||||
formattedBody,
|
||||
relation,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -78,10 +78,7 @@ describe('useAsyncCallback', () => {
|
||||
});
|
||||
|
||||
const successStates = result.current[0];
|
||||
expect(successStates.status).toBe(AsyncStatus.Success);
|
||||
if (successStates.status === AsyncStatus.Success) {
|
||||
expect(successStates.data).toBe('fresh');
|
||||
}
|
||||
expect(successStates).toMatchObject({ status: AsyncStatus.Success, data: 'fresh' });
|
||||
});
|
||||
|
||||
it('does not call setState after the component unmounts', async () => {
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
import { renderHook, act } from '@testing-library/react';
|
||||
|
||||
import { CustomAccountDataEvent } from '$types/matrix/accountData';
|
||||
|
||||
import { useExploreServers } from './useExploreServers';
|
||||
|
||||
const { callbackHolder, mockMx } = vi.hoisted(() => {
|
||||
const holder: {
|
||||
current: ((event: { getType: () => string; getContent: () => unknown }) => void) | null;
|
||||
} = { current: null };
|
||||
const mx = {
|
||||
getAccountData: vi.fn<() => { getContent: () => unknown } | null>().mockReturnValue(null),
|
||||
setAccountData: vi
|
||||
.fn<(type: string, content: { servers: string[] }) => Promise<void>>()
|
||||
.mockResolvedValue(undefined),
|
||||
};
|
||||
return { callbackHolder: holder, mockMx: mx };
|
||||
});
|
||||
|
||||
vi.mock('$hooks/useMatrixClient', () => ({
|
||||
useMatrixClient: () => mockMx,
|
||||
}));
|
||||
|
||||
vi.mock('$hooks/useAccountDataCallback', () => ({
|
||||
useAccountDataCallback: (
|
||||
_mx: unknown,
|
||||
cb: (event: { getType: () => string; getContent: () => unknown }) => void
|
||||
) => {
|
||||
callbackHolder.current = cb;
|
||||
},
|
||||
}));
|
||||
|
||||
describe('useExploreServers', () => {
|
||||
beforeEach(() => {
|
||||
mockMx.getAccountData.mockReturnValue(null);
|
||||
mockMx.setAccountData.mockClear();
|
||||
});
|
||||
|
||||
it('loads servers from account data', () => {
|
||||
mockMx.getAccountData.mockReturnValue({
|
||||
getContent: () => ({ servers: ['matrix.org', 't2bot.io'] }),
|
||||
});
|
||||
|
||||
const { result } = renderHook(() => useExploreServers());
|
||||
|
||||
expect(result.current.servers).toEqual(['matrix.org', 't2bot.io']);
|
||||
});
|
||||
|
||||
it('persists a new server to account data', async () => {
|
||||
const { result } = renderHook(() => useExploreServers());
|
||||
|
||||
await act(async () => {
|
||||
await result.current.addServer('matrix.org');
|
||||
});
|
||||
|
||||
expect(mockMx.setAccountData).toHaveBeenCalledWith(CustomAccountDataEvent.SableAddedServers, {
|
||||
servers: ['matrix.org'],
|
||||
});
|
||||
expect(result.current.servers).toEqual(['matrix.org']);
|
||||
});
|
||||
|
||||
it('does not duplicate servers case-insensitively', async () => {
|
||||
mockMx.getAccountData.mockReturnValue({
|
||||
getContent: () => ({ servers: ['matrix.org'] }),
|
||||
});
|
||||
|
||||
const { result } = renderHook(() => useExploreServers());
|
||||
|
||||
await act(async () => {
|
||||
await result.current.addServer('Matrix.org');
|
||||
});
|
||||
|
||||
expect(mockMx.setAccountData).not.toHaveBeenCalled();
|
||||
expect(result.current.servers).toEqual(['matrix.org']);
|
||||
});
|
||||
|
||||
it('rejects invalid server names', async () => {
|
||||
const { result } = renderHook(() => useExploreServers());
|
||||
|
||||
await act(async () => {
|
||||
const ok = await result.current.addServer('not a server!!!');
|
||||
expect(ok).toBe(false);
|
||||
});
|
||||
|
||||
expect(mockMx.setAccountData).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('removes a server from account data', async () => {
|
||||
mockMx.getAccountData.mockReturnValue({
|
||||
getContent: () => ({ servers: ['matrix.org', 'example.org'] }),
|
||||
});
|
||||
|
||||
const { result } = renderHook(() => useExploreServers());
|
||||
|
||||
await act(async () => {
|
||||
await result.current.removeServer('matrix.org');
|
||||
});
|
||||
|
||||
expect(mockMx.setAccountData).toHaveBeenCalledWith(CustomAccountDataEvent.SableAddedServers, {
|
||||
servers: ['example.org'],
|
||||
});
|
||||
expect(result.current.servers).toEqual(['example.org']);
|
||||
});
|
||||
|
||||
it('updates when account data changes', () => {
|
||||
const { result } = renderHook(() => useExploreServers());
|
||||
|
||||
act(() => {
|
||||
callbackHolder.current?.({
|
||||
getType: () => CustomAccountDataEvent.SableAddedServers,
|
||||
getContent: () => ({ servers: ['example.org'] }),
|
||||
});
|
||||
});
|
||||
|
||||
expect(result.current.servers).toEqual(['example.org']);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,70 @@
|
||||
import { useCallback, useState } from 'react';
|
||||
|
||||
import { CustomAccountDataEvent, type AddedServersContent } from '$types/matrix/accountData';
|
||||
import { isServerName } from '$utils/matrix';
|
||||
|
||||
import { useAccountDataCallback } from './useAccountDataCallback';
|
||||
import { useMatrixClient } from './useMatrixClient';
|
||||
|
||||
const serverKey = (server: string): string => server.toLowerCase();
|
||||
|
||||
const hasServer = (servers: string[], server: string): boolean =>
|
||||
servers.some((entry) => serverKey(entry) === serverKey(server));
|
||||
|
||||
const readAddedServers = (content: unknown): string[] => {
|
||||
if (!content || typeof content !== 'object') return [];
|
||||
const servers = (content as AddedServersContent).servers;
|
||||
if (!Array.isArray(servers)) return [];
|
||||
return servers.filter((server): server is string => typeof server === 'string');
|
||||
};
|
||||
|
||||
export const useExploreServers = () => {
|
||||
const mx = useMatrixClient();
|
||||
const [servers, setServers] = useState<string[]>(() =>
|
||||
readAddedServers(mx.getAccountData(CustomAccountDataEvent.SableAddedServers)?.getContent())
|
||||
);
|
||||
|
||||
useAccountDataCallback(
|
||||
mx,
|
||||
useCallback((mEvent) => {
|
||||
if (mEvent.getType() !== (CustomAccountDataEvent.SableAddedServers as string)) return;
|
||||
setServers(readAddedServers(mEvent.getContent()));
|
||||
}, [])
|
||||
);
|
||||
|
||||
const addServer = useCallback(
|
||||
async (server: string): Promise<boolean> => {
|
||||
const normalized = server.trim();
|
||||
if (!isServerName(normalized)) return false;
|
||||
|
||||
const current = readAddedServers(
|
||||
mx.getAccountData(CustomAccountDataEvent.SableAddedServers)?.getContent()
|
||||
);
|
||||
if (hasServer(current, normalized)) return true;
|
||||
|
||||
const next: AddedServersContent = { servers: [...current, normalized] };
|
||||
await mx.setAccountData(CustomAccountDataEvent.SableAddedServers, next);
|
||||
setServers(next.servers);
|
||||
return true;
|
||||
},
|
||||
[mx]
|
||||
);
|
||||
|
||||
const removeServer = useCallback(
|
||||
async (server: string): Promise<boolean> => {
|
||||
const current = readAddedServers(
|
||||
mx.getAccountData(CustomAccountDataEvent.SableAddedServers)?.getContent()
|
||||
);
|
||||
const nextServers = current.filter((entry) => serverKey(entry) !== serverKey(server));
|
||||
if (nextServers.length === current.length) return false;
|
||||
|
||||
const next: AddedServersContent = { servers: nextServers };
|
||||
await mx.setAccountData(CustomAccountDataEvent.SableAddedServers, next);
|
||||
setServers(next.servers);
|
||||
return true;
|
||||
},
|
||||
[mx]
|
||||
);
|
||||
|
||||
return { servers, addServer, removeServer };
|
||||
};
|
||||
@@ -56,36 +56,102 @@ export type ParsedResult = {
|
||||
|
||||
export type MemberEventParser = (mEvent: MatrixEvent) => ParsedResult;
|
||||
|
||||
export const useMemberEventParser = (): MemberEventParser => {
|
||||
const parseMemberEvent: MemberEventParser = (mEvent) => {
|
||||
const content = mEvent.getContent<IMemberContent>();
|
||||
const prevContent = mEvent.getPrevContent() as IMemberContent;
|
||||
const senderId = mEvent.getSender();
|
||||
const userId = mEvent.getStateKey();
|
||||
const roomId = mEvent.getRoomId();
|
||||
const reason = typeof content.reason === 'string' ? content.reason : undefined;
|
||||
const parseMemberEvent: MemberEventParser = (mEvent) => {
|
||||
const content = mEvent.getContent<IMemberContent>();
|
||||
const prevContent = mEvent.getPrevContent() as IMemberContent;
|
||||
const senderId = mEvent.getSender();
|
||||
const userId = mEvent.getStateKey();
|
||||
const roomId = mEvent.getRoomId();
|
||||
const reason = typeof content.reason === 'string' ? content.reason : undefined;
|
||||
|
||||
if (!senderId || !userId)
|
||||
return {
|
||||
icon: timelineIcon(User),
|
||||
body: 'Broken membership event',
|
||||
};
|
||||
|
||||
const senderName = getMxIdLocalPart(senderId);
|
||||
const userName =
|
||||
typeof content.displayname === 'string'
|
||||
? content.displayname || getMxIdLocalPart(userId)
|
||||
: getMxIdLocalPart(userId);
|
||||
|
||||
if (isMembershipChanged(mEvent)) {
|
||||
if (content.membership === KnownMembership.Invite) {
|
||||
if (prevContent.membership === KnownMembership.Knock) {
|
||||
return {
|
||||
icon: timelineIcon(UserPlus),
|
||||
body: (
|
||||
<>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={senderId} userName={senderName} />
|
||||
<Text>{' accepted '}</Text>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={userId} userName={userName} />
|
||||
<Text>
|
||||
{`'s join request `}
|
||||
{reason}
|
||||
</Text>
|
||||
</>
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
if (!senderId || !userId)
|
||||
return {
|
||||
icon: timelineIcon(User),
|
||||
body: 'Broken membership event',
|
||||
icon: timelineIcon(UserPlus),
|
||||
body: (
|
||||
<>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={senderId} userName={senderName} />
|
||||
<Text>{' invited '}</Text>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={userId} userName={userName} />
|
||||
<Text>{reason}</Text>
|
||||
</>
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
const senderName = getMxIdLocalPart(senderId);
|
||||
const userName =
|
||||
typeof content.displayname === 'string'
|
||||
? content.displayname || getMxIdLocalPart(userId)
|
||||
: getMxIdLocalPart(userId);
|
||||
if (content.membership === KnownMembership.Knock) {
|
||||
return {
|
||||
icon: timelineIcon(EnvelopeSimple),
|
||||
body: (
|
||||
<>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={userId} userName={userName} />
|
||||
<Text>
|
||||
{' requested to join room: '}
|
||||
<i>{reason}</i>
|
||||
</Text>
|
||||
</>
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
if (isMembershipChanged(mEvent)) {
|
||||
if (content.membership === KnownMembership.Invite) {
|
||||
if (prevContent.membership === KnownMembership.Knock) {
|
||||
return {
|
||||
icon: timelineIcon(UserPlus),
|
||||
body: (
|
||||
if (content.membership === KnownMembership.Join) {
|
||||
return {
|
||||
icon: timelineIcon(SignIn),
|
||||
body: (
|
||||
<>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={userId} userName={userName} />
|
||||
<Text>{' joined the room'}</Text>
|
||||
</>
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
if (content.membership === KnownMembership.Leave) {
|
||||
if (prevContent.membership === KnownMembership.Invite) {
|
||||
return {
|
||||
icon: timelineIcon(UserMinus),
|
||||
body:
|
||||
senderId === userId ? (
|
||||
<>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={userId} userName={userName} />
|
||||
<Text>
|
||||
{' rejected the invitation '}
|
||||
{reason}
|
||||
</Text>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={senderId} userName={senderName} />
|
||||
<Text>{' accepted '}</Text>
|
||||
<Text>{' rejected '}</Text>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={userId} userName={userName} />
|
||||
<Text>
|
||||
{`'s join request `}
|
||||
@@ -93,199 +159,131 @@ export const useMemberEventParser = (): MemberEventParser => {
|
||||
</Text>
|
||||
</>
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
icon: timelineIcon(UserPlus),
|
||||
body: (
|
||||
<>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={senderId} userName={senderName} />
|
||||
<Text>{' invited '}</Text>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={userId} userName={userName} />
|
||||
<Text>{reason}</Text>
|
||||
</>
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
if (content.membership === KnownMembership.Knock) {
|
||||
if (prevContent.membership === KnownMembership.Knock) {
|
||||
return {
|
||||
icon: timelineIcon(EnvelopeSimple),
|
||||
body: (
|
||||
<>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={userId} userName={userName} />
|
||||
<Text>
|
||||
{' requested to join room: '}
|
||||
<i>{reason}</i>
|
||||
</Text>
|
||||
</>
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
if (content.membership === KnownMembership.Join) {
|
||||
return {
|
||||
icon: timelineIcon(SignIn),
|
||||
body: (
|
||||
<>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={userId} userName={userName} />
|
||||
<Text>{' joined the room'}</Text>
|
||||
</>
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
if (content.membership === KnownMembership.Leave) {
|
||||
if (prevContent.membership === KnownMembership.Invite) {
|
||||
return {
|
||||
icon: timelineIcon(UserMinus),
|
||||
body:
|
||||
senderId === userId ? (
|
||||
<>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={userId} userName={userName} />
|
||||
<Text>
|
||||
{' rejected the invitation '}
|
||||
{reason}
|
||||
</Text>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={senderId} userName={senderName} />
|
||||
<Text>{' rejected '}</Text>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={userId} userName={userName} />
|
||||
<Text>
|
||||
{`'s join request `}
|
||||
{reason}
|
||||
</Text>
|
||||
</>
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
if (prevContent.membership === KnownMembership.Knock) {
|
||||
return {
|
||||
icon: timelineIcon(UserMinus),
|
||||
body:
|
||||
senderId === userId ? (
|
||||
<>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={userId} userName={userName} />
|
||||
<Text>
|
||||
{' revoked joined request '}
|
||||
{reason}
|
||||
</Text>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={senderId} userName={senderName} />
|
||||
{' revoked '}
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={userId} userName={userName} />
|
||||
<Text>
|
||||
{`'s invite `}
|
||||
{reason}
|
||||
</Text>
|
||||
</>
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
if (prevContent.membership === KnownMembership.Ban) {
|
||||
return {
|
||||
icon: timelineIcon(SignOut),
|
||||
body: (
|
||||
<>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={senderId} userName={senderName} />
|
||||
<Text>{' unbanned '}</Text>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={userId} userName={userName} />
|
||||
<Text>{reason}</Text>
|
||||
</>
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
icon: timelineIcon(SignOut),
|
||||
icon: timelineIcon(UserMinus),
|
||||
body:
|
||||
senderId === userId ? (
|
||||
<>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={userId} userName={userName} />
|
||||
<Text>
|
||||
{' left the room '}
|
||||
{' revoked joined request '}
|
||||
{reason}
|
||||
</Text>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={senderId} userName={senderName} />
|
||||
<Text>{' kicked '}</Text>
|
||||
{' revoked '}
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={userId} userName={userName} />
|
||||
<Text>{reason}</Text>
|
||||
<Text>
|
||||
{`'s invite `}
|
||||
{reason}
|
||||
</Text>
|
||||
</>
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
if (content.membership === KnownMembership.Ban) {
|
||||
if (prevContent.membership === KnownMembership.Ban) {
|
||||
return {
|
||||
icon: timelineIcon(SignOut),
|
||||
body: (
|
||||
<>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={senderId} userName={senderName} />
|
||||
<Text>{' banned '}</Text>
|
||||
<Text>{' unbanned '}</Text>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={userId} userName={userName} />
|
||||
<Text>{reason}</Text>
|
||||
</>
|
||||
),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (content.displayname !== prevContent.displayname) {
|
||||
const prevUserName =
|
||||
typeof prevContent.displayname === 'string'
|
||||
? prevContent.displayname || getMxIdLocalPart(userId)
|
||||
: getMxIdLocalPart(userId);
|
||||
|
||||
return {
|
||||
icon: timelineIcon(At),
|
||||
icon: timelineIcon(SignOut),
|
||||
body:
|
||||
typeof content.displayname === 'string' ? (
|
||||
senderId === userId ? (
|
||||
<>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={userId} userName={prevUserName} />
|
||||
<Text>{' changed display name to '}</Text>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={userId} userName={userName} />
|
||||
<Text>
|
||||
{' left the room '}
|
||||
{reason}
|
||||
</Text>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={userId} userName={prevUserName} />
|
||||
<Text>{' removed their display name '}</Text>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={senderId} userName={senderName} />
|
||||
<Text>{' kicked '}</Text>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={userId} userName={userName} />
|
||||
<Text>{reason}</Text>
|
||||
</>
|
||||
),
|
||||
};
|
||||
}
|
||||
if (content.avatar_url !== prevContent.avatar_url) {
|
||||
|
||||
if (content.membership === KnownMembership.Ban) {
|
||||
return {
|
||||
icon: timelineIcon(User),
|
||||
body:
|
||||
content.avatar_url && typeof content.avatar_url === 'string' ? (
|
||||
<>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={userId} userName={userName} />
|
||||
<Text>{' changed their avatar'}</Text>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={userId} userName={userName} />
|
||||
<Text>{' removed their avatar '}</Text>
|
||||
</>
|
||||
),
|
||||
icon: timelineIcon(SignOut),
|
||||
body: (
|
||||
<>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={senderId} userName={senderName} />
|
||||
<Text>{' banned '}</Text>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={userId} userName={userName} />
|
||||
<Text>{reason}</Text>
|
||||
</>
|
||||
),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (content.displayname !== prevContent.displayname) {
|
||||
const prevUserName =
|
||||
typeof prevContent.displayname === 'string'
|
||||
? prevContent.displayname || getMxIdLocalPart(userId)
|
||||
: getMxIdLocalPart(userId);
|
||||
|
||||
return {
|
||||
icon: timelineIcon(User),
|
||||
body: 'Membership event with no changes',
|
||||
icon: timelineIcon(At),
|
||||
body:
|
||||
typeof content.displayname === 'string' ? (
|
||||
<>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={userId} userName={prevUserName} />
|
||||
<Text>{' changed display name to '}</Text>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={userId} userName={userName} />
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={userId} userName={prevUserName} />
|
||||
<Text>{' removed their display name '}</Text>
|
||||
</>
|
||||
),
|
||||
};
|
||||
};
|
||||
}
|
||||
if (content.avatar_url !== prevContent.avatar_url) {
|
||||
return {
|
||||
icon: timelineIcon(User),
|
||||
body:
|
||||
content.avatar_url && typeof content.avatar_url === 'string' ? (
|
||||
<>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={userId} userName={userName} />
|
||||
<Text>{' changed their avatar'}</Text>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<DecoratedUser roomId={roomId ?? ''} userId={userId} userName={userName} />
|
||||
<Text>{' removed their avatar '}</Text>
|
||||
</>
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
return parseMemberEvent;
|
||||
return {
|
||||
icon: timelineIcon(User),
|
||||
body: 'Membership event with no changes',
|
||||
};
|
||||
};
|
||||
|
||||
export const useMemberEventParser = (): MemberEventParser => parseMemberEvent;
|
||||
+33
-21
@@ -1,4 +1,4 @@
|
||||
import { lazy, Suspense, useRef } from 'react';
|
||||
import { lazy, Suspense, useCallback, useRef } from 'react';
|
||||
import { Provider as JotaiProvider } from 'jotai';
|
||||
import { createStore } from 'jotai/vanilla';
|
||||
import { OverlayContainerProvider, PopOutContainerProvider, TooltipContainerProvider } from 'folds';
|
||||
@@ -56,37 +56,49 @@ function BootstrappedAppShell({ clientConfig, screenSize }: BootstrappedAppShell
|
||||
);
|
||||
}
|
||||
|
||||
function renderSentryErrorFallback({ error, eventId }: { error: unknown; eventId: string | null }) {
|
||||
return (
|
||||
<ErrorPage
|
||||
error={error instanceof Error ? error : new Error(String(error))}
|
||||
eventId={eventId || undefined}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function appConfigFallback() {
|
||||
return <ConfigConfigLoading />;
|
||||
}
|
||||
|
||||
function appConfigError(err: unknown, retry: () => void, ignore: () => void) {
|
||||
return <ConfigConfigError error={err} retry={retry} ignore={ignore} />;
|
||||
}
|
||||
|
||||
function AppConfigLoaded({ clientConfig, screenSize }: BootstrappedAppShellProps) {
|
||||
setMatrixToBase(clientConfig.matrixToBaseUrl);
|
||||
return <BootstrappedAppShell clientConfig={clientConfig} screenSize={screenSize} />;
|
||||
}
|
||||
|
||||
function App() {
|
||||
const screenSize = useScreenSize();
|
||||
useCompositionEndTracking();
|
||||
const portalContainer = document.getElementById('portalContainer') ?? undefined;
|
||||
|
||||
const renderAppConfig = useCallback(
|
||||
(clientConfig: ClientConfig) => (
|
||||
<AppConfigLoaded clientConfig={clientConfig} screenSize={screenSize} />
|
||||
),
|
||||
[screenSize]
|
||||
);
|
||||
|
||||
return (
|
||||
<Sentry.ErrorBoundary
|
||||
fallback={({ error, eventId }) => (
|
||||
<ErrorPage
|
||||
error={error instanceof Error ? error : new Error(String(error))}
|
||||
eventId={eventId || undefined}
|
||||
/>
|
||||
)}
|
||||
>
|
||||
<Sentry.ErrorBoundary fallback={renderSentryErrorFallback}>
|
||||
<TooltipContainerProvider value={portalContainer}>
|
||||
<PopOutContainerProvider value={portalContainer}>
|
||||
<OverlayContainerProvider value={portalContainer}>
|
||||
<ScreenSizeProvider value={screenSize}>
|
||||
<FeatureCheck>
|
||||
<ClientConfigLoader
|
||||
fallback={() => <ConfigConfigLoading />}
|
||||
error={(err, retry, ignore) => (
|
||||
<ConfigConfigError error={err} retry={retry} ignore={ignore} />
|
||||
)}
|
||||
>
|
||||
{(clientConfig) => {
|
||||
setMatrixToBase(clientConfig.matrixToBaseUrl);
|
||||
return (
|
||||
<BootstrappedAppShell clientConfig={clientConfig} screenSize={screenSize} />
|
||||
);
|
||||
}}
|
||||
<ClientConfigLoader fallback={appConfigFallback} error={appConfigError}>
|
||||
{renderAppConfig}
|
||||
</ClientConfigLoader>
|
||||
</FeatureCheck>
|
||||
</ScreenSizeProvider>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { ReactNode } from 'react';
|
||||
import { useCallback, useEffect } from 'react';
|
||||
import { Box, Chip, Header, Scroll, Spinner, Text, color } from 'folds';
|
||||
import {
|
||||
@@ -20,10 +21,12 @@ import { SpecVersionsProvider } from '$hooks/useSpecVersions';
|
||||
import { AutoDiscoveryInfoProvider } from '$hooks/useAutoDiscoveryInfo';
|
||||
import { AuthFlowsLoader } from '$components/AuthFlowsLoader';
|
||||
import { AuthFlowsProvider } from '$hooks/useAuthFlows';
|
||||
import type { AuthFlows } from '$hooks/useAuthFlows';
|
||||
import { AuthServerProvider } from '$hooks/useAuthServer';
|
||||
import { LOGIN_PATH, REGISTER_PATH, RESET_PASSWORD_PATH } from '$pages/paths';
|
||||
import { getHomePath } from '$pages/pathUtils';
|
||||
import { AutoDiscoveryAction, autoDiscovery } from '../../cs-api';
|
||||
import type { SpecVersions } from '../../cs-api';
|
||||
import { ServerPicker } from './ServerPicker';
|
||||
import * as css from './styles.css';
|
||||
import { AuthFooter } from './AuthFooter';
|
||||
@@ -62,6 +65,48 @@ function AuthLayoutError({ message }: { message: string }) {
|
||||
);
|
||||
}
|
||||
|
||||
function AuthHomeserverConnectFallback({ baseUrl }: { baseUrl: string }) {
|
||||
return <AuthLayoutLoading message={`Connecting to ${baseUrl}`} />;
|
||||
}
|
||||
|
||||
function authHomeserverConnectError() {
|
||||
return (
|
||||
<AuthLayoutError message="Failed to connect. Either homeserver is unavailable at this moment or does not exist." />
|
||||
);
|
||||
}
|
||||
|
||||
function authFlowsLoadingFallback() {
|
||||
return <AuthLayoutLoading message="Loading authentication flow..." />;
|
||||
}
|
||||
|
||||
function authFlowsError() {
|
||||
return <AuthLayoutError message="Failed to get authentication flow information." />;
|
||||
}
|
||||
|
||||
function AuthFlowsOutlet({ authFlows }: { authFlows: AuthFlows }) {
|
||||
return (
|
||||
<AuthFlowsProvider value={authFlows}>
|
||||
<Outlet />
|
||||
</AuthFlowsProvider>
|
||||
);
|
||||
}
|
||||
|
||||
function AuthSpecVersionsContent({
|
||||
specVersions,
|
||||
renderAuthFlows,
|
||||
}: {
|
||||
specVersions: SpecVersions;
|
||||
renderAuthFlows: (authFlows: AuthFlows) => ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<SpecVersionsProvider value={specVersions}>
|
||||
<AuthFlowsLoader fallback={authFlowsLoadingFallback} error={authFlowsError}>
|
||||
{renderAuthFlows}
|
||||
</AuthFlowsLoader>
|
||||
</SpecVersionsProvider>
|
||||
);
|
||||
}
|
||||
|
||||
export function AuthLayout() {
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
@@ -124,6 +169,25 @@ export function AuthLayout() {
|
||||
const [autoDiscoveryError, autoDiscoveryInfo] =
|
||||
discoveryState.status === AsyncStatus.Success ? discoveryState.data.response : [];
|
||||
|
||||
const homeserverBaseUrl = autoDiscoveryInfo?.['m.homeserver']?.base_url;
|
||||
|
||||
const renderHomeserverConnectFallback = useCallback(() => {
|
||||
if (!homeserverBaseUrl) return null;
|
||||
return <AuthHomeserverConnectFallback baseUrl={homeserverBaseUrl} />;
|
||||
}, [homeserverBaseUrl]);
|
||||
|
||||
const renderAuthFlows = useCallback(
|
||||
(authFlows: AuthFlows) => <AuthFlowsOutlet authFlows={authFlows} />,
|
||||
[]
|
||||
);
|
||||
|
||||
const renderSpecVersions = useCallback(
|
||||
(specVersions: SpecVersions) => (
|
||||
<AuthSpecVersionsContent specVersions={specVersions} renderAuthFlows={renderAuthFlows} />
|
||||
),
|
||||
[renderAuthFlows]
|
||||
);
|
||||
|
||||
return (
|
||||
<Scroll variant="Background" visibility="Hover" size="300" hideTrack>
|
||||
<Box
|
||||
@@ -185,33 +249,10 @@ export function AuthLayout() {
|
||||
<AutoDiscoveryInfoProvider value={autoDiscoveryInfo}>
|
||||
<SpecVersionsLoader
|
||||
baseUrl={autoDiscoveryInfo['m.homeserver'].base_url}
|
||||
fallback={() => (
|
||||
<AuthLayoutLoading
|
||||
message={`Connecting to ${autoDiscoveryInfo['m.homeserver'].base_url}`}
|
||||
/>
|
||||
)}
|
||||
error={() => (
|
||||
<AuthLayoutError message="Failed to connect. Either homeserver is unavailable at this moment or does not exist." />
|
||||
)}
|
||||
fallback={renderHomeserverConnectFallback}
|
||||
error={authHomeserverConnectError}
|
||||
>
|
||||
{(specVersions) => (
|
||||
<SpecVersionsProvider value={specVersions}>
|
||||
<AuthFlowsLoader
|
||||
fallback={() => (
|
||||
<AuthLayoutLoading message="Loading authentication flow..." />
|
||||
)}
|
||||
error={() => (
|
||||
<AuthLayoutError message="Failed to get authentication flow information." />
|
||||
)}
|
||||
>
|
||||
{(authFlows) => (
|
||||
<AuthFlowsProvider value={authFlows}>
|
||||
<Outlet />
|
||||
</AuthFlowsProvider>
|
||||
)}
|
||||
</AuthFlowsLoader>
|
||||
</SpecVersionsProvider>
|
||||
)}
|
||||
{renderSpecVersions}
|
||||
</SpecVersionsLoader>
|
||||
</AutoDiscoveryInfoProvider>
|
||||
</AuthServerProvider>
|
||||
|
||||
@@ -178,6 +178,7 @@ function InviteNotifications() {
|
||||
const [showSystemNotifications] = useSetting(settingsAtom, 'useSystemNotifications');
|
||||
const [usePushNotifications] = useSetting(settingsAtom, 'usePushNotifications');
|
||||
const [notificationSound] = useSetting(settingsAtom, 'isNotificationSounds');
|
||||
const [backgroundNotificationSounds] = useSetting(settingsAtom, 'backgroundNotificationSounds');
|
||||
|
||||
const notify = useCallback(
|
||||
(count: number) => {
|
||||
@@ -198,7 +199,7 @@ function InviteNotifications() {
|
||||
|
||||
const playSound = useCallback(() => {
|
||||
const audioElement = audioRef.current;
|
||||
audioElement?.play();
|
||||
audioElement?.play()?.catch(() => {});
|
||||
clearMediaSessionQuickly();
|
||||
}, []);
|
||||
|
||||
@@ -216,8 +217,8 @@ function InviteNotifications() {
|
||||
// window.Notification may be unavailable in sandboxed environments.
|
||||
}
|
||||
}
|
||||
// Audio API requires a visible document; skip when hidden.
|
||||
if (document.visibilityState === 'visible' && notificationSound) {
|
||||
const tabVisible = document.visibilityState === 'visible';
|
||||
if (notificationSound && (tabVisible || backgroundNotificationSounds)) {
|
||||
playSound();
|
||||
}
|
||||
}, [
|
||||
@@ -227,6 +228,7 @@ function InviteNotifications() {
|
||||
showSystemNotifications,
|
||||
usePushNotifications,
|
||||
notificationSound,
|
||||
backgroundNotificationSounds,
|
||||
notify,
|
||||
playSound,
|
||||
]);
|
||||
@@ -253,6 +255,7 @@ function MessageNotifications() {
|
||||
const [showSystemNotifications] = useSetting(settingsAtom, 'useSystemNotifications');
|
||||
const [usePushNotifications] = useSetting(settingsAtom, 'usePushNotifications');
|
||||
const [notificationSound] = useSetting(settingsAtom, 'isNotificationSounds');
|
||||
const [backgroundNotificationSounds] = useSetting(settingsAtom, 'backgroundNotificationSounds');
|
||||
const [showMessageContent] = useSetting(settingsAtom, 'showMessageContentInNotifications');
|
||||
const [showEncryptedMessageContent] = useSetting(
|
||||
settingsAtom,
|
||||
@@ -272,7 +275,7 @@ function MessageNotifications() {
|
||||
|
||||
const playSound = useCallback(() => {
|
||||
const audioElement = audioRef.current;
|
||||
audioElement?.play();
|
||||
audioElement?.play()?.catch(() => {});
|
||||
clearMediaSessionQuickly();
|
||||
}, []);
|
||||
|
||||
@@ -453,8 +456,13 @@ function MessageNotifications() {
|
||||
}
|
||||
}
|
||||
|
||||
// Everything below requires the page to be visible (in-app UI + audio).
|
||||
if (document.visibilityState !== 'visible') return;
|
||||
const tabVisible = document.visibilityState === 'visible';
|
||||
if (notificationSound && isLoud && (tabVisible || backgroundNotificationSounds)) {
|
||||
playSound();
|
||||
}
|
||||
|
||||
// In-app banner requires a visible tab.
|
||||
if (!tabVisible) return;
|
||||
|
||||
// Page is visible — show the themed in-app notification banner.
|
||||
// For non-DM rooms, only show banner for highlighted messages (mentions/keywords).
|
||||
@@ -530,11 +538,6 @@ function MessageNotifications() {
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// In-app audio: play when notification sounds are enabled AND this notification is loud.
|
||||
if (notificationSound && isLoud) {
|
||||
playSound();
|
||||
}
|
||||
};
|
||||
mx.on(RoomEvent.Timeline, handleTimelineEvent);
|
||||
return () => {
|
||||
@@ -543,6 +546,7 @@ function MessageNotifications() {
|
||||
}, [
|
||||
mx,
|
||||
notificationSound,
|
||||
backgroundNotificationSounds,
|
||||
notificationSelected,
|
||||
showNotifications,
|
||||
showSystemNotifications,
|
||||
|
||||
@@ -1,46 +1,59 @@
|
||||
import type { ReactNode } from 'react';
|
||||
import { useCallback } from 'react';
|
||||
import { Box, Dialog, config, Text, Button, Spinner } from 'folds';
|
||||
import { SpecVersionsLoader } from '$components/SpecVersionsLoader';
|
||||
import { SpecVersionsProvider } from '$hooks/useSpecVersions';
|
||||
import type { SpecVersions } from '../../cs-api';
|
||||
import { SplashScreen } from '$components/splash-screen';
|
||||
|
||||
export function SpecVersions({ baseUrl, children }: { baseUrl: string; children: ReactNode }) {
|
||||
function specVersionsFallback() {
|
||||
return (
|
||||
<SpecVersionsLoader
|
||||
baseUrl={baseUrl}
|
||||
fallback={() => (
|
||||
<SplashScreen>
|
||||
<Box direction="Column" grow="Yes" alignItems="Center" justifyContent="Center" gap="400">
|
||||
<Spinner variant="Secondary" size="600" />
|
||||
<Text>Connecting to server</Text>
|
||||
<SplashScreen>
|
||||
<Box direction="Column" grow="Yes" alignItems="Center" justifyContent="Center" gap="400">
|
||||
<Spinner variant="Secondary" size="600" />
|
||||
<Text>Connecting to server</Text>
|
||||
</Box>
|
||||
</SplashScreen>
|
||||
);
|
||||
}
|
||||
|
||||
function specVersionsError(_err: unknown, retry: () => void, ignore: () => void) {
|
||||
return (
|
||||
<SplashScreen>
|
||||
<Box direction="Column" grow="Yes" alignItems="Center" justifyContent="Center" gap="400">
|
||||
<Dialog>
|
||||
<Box direction="Column" gap="400" style={{ padding: config.space.S400 }}>
|
||||
<Text>
|
||||
Failed to connect to homeserver. Either homeserver is down or your internet.
|
||||
</Text>
|
||||
<Button variant="Critical" onClick={retry}>
|
||||
<Text as="span" size="B400">
|
||||
Retry
|
||||
</Text>
|
||||
</Button>
|
||||
<Button variant="Critical" onClick={ignore} fill="Soft">
|
||||
<Text as="span" size="B400">
|
||||
Continue
|
||||
</Text>
|
||||
</Button>
|
||||
</Box>
|
||||
</SplashScreen>
|
||||
)}
|
||||
error={(err, retry, ignore) => (
|
||||
<SplashScreen>
|
||||
<Box direction="Column" grow="Yes" alignItems="Center" justifyContent="Center" gap="400">
|
||||
<Dialog>
|
||||
<Box direction="Column" gap="400" style={{ padding: config.space.S400 }}>
|
||||
<Text>
|
||||
Failed to connect to homeserver. Either homeserver is down or your internet.
|
||||
</Text>
|
||||
<Button variant="Critical" onClick={retry}>
|
||||
<Text as="span" size="B400">
|
||||
Retry
|
||||
</Text>
|
||||
</Button>
|
||||
<Button variant="Critical" onClick={ignore} fill="Soft">
|
||||
<Text as="span" size="B400">
|
||||
Continue
|
||||
</Text>
|
||||
</Button>
|
||||
</Box>
|
||||
</Dialog>
|
||||
</Box>
|
||||
</SplashScreen>
|
||||
)}
|
||||
>
|
||||
{(versions) => <SpecVersionsProvider value={versions}>{children}</SpecVersionsProvider>}
|
||||
</Dialog>
|
||||
</Box>
|
||||
</SplashScreen>
|
||||
);
|
||||
}
|
||||
|
||||
export function SpecVersions({ baseUrl, children }: { baseUrl: string; children: ReactNode }) {
|
||||
const renderChildren = useCallback(
|
||||
(versions: SpecVersions) => (
|
||||
<SpecVersionsProvider value={versions}>{children}</SpecVersionsProvider>
|
||||
),
|
||||
[children]
|
||||
);
|
||||
|
||||
return (
|
||||
<SpecVersionsLoader baseUrl={baseUrl} fallback={specVersionsFallback} error={specVersionsError}>
|
||||
{renderChildren}
|
||||
</SpecVersionsLoader>
|
||||
);
|
||||
}
|
||||
@@ -21,7 +21,7 @@ import {
|
||||
DotsThreeOutlineVerticalIcon,
|
||||
dropzoneIcon,
|
||||
menuIcon,
|
||||
getPhosphorSize,
|
||||
getPhosphorIconSize,
|
||||
Plus,
|
||||
User,
|
||||
} from '$components/icons/phosphor';
|
||||
@@ -115,7 +115,10 @@ function DirectHeader({ hideText }: { hideText?: boolean }) {
|
||||
{hideText ? (
|
||||
<Box alignItems="Center" grow="Yes" justifyContent="Center">
|
||||
<IconButton aria-pressed={!!menuAnchor} variant="Background" onClick={handleOpenMenu}>
|
||||
<User size={getPhosphorSize().toolbar} weight={menuAnchor ? 'fill' : 'regular'} />
|
||||
<User
|
||||
size={getPhosphorIconSize('toolbar')}
|
||||
weight={menuAnchor ? 'fill' : 'regular'}
|
||||
/>
|
||||
</IconButton>
|
||||
</Box>
|
||||
) : (
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { FormEventHandler } from 'react';
|
||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import type { FormEventHandler, MouseEventHandler } from 'react';
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import FocusTrap from 'focus-trap-react';
|
||||
import {
|
||||
@@ -23,15 +23,24 @@ import {
|
||||
HardDrives,
|
||||
Lightbulb,
|
||||
Plus,
|
||||
Trash,
|
||||
X,
|
||||
composerIcon,
|
||||
sizedIcon,
|
||||
menuIcon,
|
||||
} from '$components/icons/phosphor';
|
||||
import { NavCategory, NavCategoryHeader, NavItem, NavItemContent, NavLink } from '$components/nav';
|
||||
import {
|
||||
NavCategory,
|
||||
NavCategoryHeader,
|
||||
NavItem,
|
||||
NavItemContent,
|
||||
NavItemOptions,
|
||||
NavLink,
|
||||
} from '$components/nav';
|
||||
import { getExploreFeaturedPath, getExploreServerPath } from '$pages/pathUtils';
|
||||
import { useClientConfig } from '$hooks/useClientConfig';
|
||||
import { useExploreFeaturedSelected, useExploreServer } from '$hooks/router/useExploreSelected';
|
||||
import { useExploreServers } from '$hooks/useExploreServers';
|
||||
import { useMatrixClient } from '$hooks/useMatrixClient';
|
||||
import { AsyncStatus, useAsyncCallback } from '$hooks/useAsyncCallback';
|
||||
import { useNavToActivePathMapper } from '$hooks/useNavToActivePathMapper';
|
||||
@@ -41,12 +50,19 @@ import { SidebarResizer } from '$pages/client/sidebar/SidebarResizer';
|
||||
import { settingsAtom } from '$state/settings';
|
||||
import { useSetting } from '$state/hooks/settings';
|
||||
import { getMxIdServer } from '$utils/mxIdHelper';
|
||||
import { isServerName } from '$utils/matrix';
|
||||
import { useScreenSizeContext, ScreenSize } from '$hooks/useScreenSize';
|
||||
|
||||
export function AddServer({ hideText }: { hideText?: boolean }) {
|
||||
type AddServerProps = {
|
||||
hideText?: boolean;
|
||||
onAddServer: (server: string) => Promise<boolean>;
|
||||
};
|
||||
|
||||
export function AddServer({ hideText, onAddServer }: AddServerProps) {
|
||||
const mx = useMatrixClient();
|
||||
const navigate = useNavigate();
|
||||
const [dialog, setDialog] = useState(false);
|
||||
const [serverError, setServerError] = useState<string>();
|
||||
const serverInputRef = useRef<HTMLInputElement>(null);
|
||||
|
||||
const [exploreState] = useAsyncCallback(
|
||||
@@ -60,21 +76,33 @@ export function AddServer({ hideText }: { hideText?: boolean }) {
|
||||
return server || undefined;
|
||||
};
|
||||
|
||||
const addAndNavigate = useCallback(
|
||||
async (server: string) => {
|
||||
if (!isServerName(server)) {
|
||||
setServerError('Invalid server name.');
|
||||
return;
|
||||
}
|
||||
|
||||
setServerError(undefined);
|
||||
const added = await onAddServer(server);
|
||||
if (!added) {
|
||||
setServerError('Failed to save server. Please try again.');
|
||||
return;
|
||||
}
|
||||
|
||||
navigate(getExploreServerPath(server));
|
||||
setDialog(false);
|
||||
},
|
||||
[navigate, onAddServer]
|
||||
);
|
||||
|
||||
const handleSubmit: FormEventHandler<HTMLFormElement> = (evt) => {
|
||||
evt.preventDefault();
|
||||
const server = getInputServer();
|
||||
if (!server) return;
|
||||
// explore(server);
|
||||
|
||||
navigate(getExploreServerPath(server));
|
||||
setDialog(false);
|
||||
};
|
||||
|
||||
const handleView = () => {
|
||||
const server = getInputServer();
|
||||
if (!server) return;
|
||||
navigate(getExploreServerPath(server));
|
||||
setDialog(false);
|
||||
addAndNavigate(server).catch(() => {
|
||||
setServerError('Failed to save server. Please try again.');
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -116,6 +144,11 @@ export function AddServer({ hideText }: { hideText?: boolean }) {
|
||||
<Box direction="Column" gap="100">
|
||||
<Text size="L400">Server Name</Text>
|
||||
<Input ref={serverInputRef} name="serverInput" variant="Background" required />
|
||||
{serverError && (
|
||||
<Text style={{ color: color.Critical.Main }} size="T300">
|
||||
{serverError}
|
||||
</Text>
|
||||
)}
|
||||
{exploreState.status === AsyncStatus.Error && (
|
||||
<Text style={{ color: color.Critical.Main }} size="T300">
|
||||
Failed to load public rooms. Please try again.
|
||||
@@ -136,8 +169,8 @@ export function AddServer({ hideText }: { hideText?: boolean }) {
|
||||
<Text size="B400">Save</Text>
|
||||
</Button> */}
|
||||
|
||||
<Button type="submit" onClick={handleView} variant="Secondary" fill="Soft">
|
||||
<Text size="B400">View</Text>
|
||||
<Button type="submit" variant="Secondary" fill="Soft">
|
||||
<Text size="B400">Add</Text>
|
||||
</Button>
|
||||
</Box>
|
||||
</Box>
|
||||
@@ -168,16 +201,60 @@ export function AddServer({ hideText }: { hideText?: boolean }) {
|
||||
|
||||
export function Explore() {
|
||||
const mx = useMatrixClient();
|
||||
const navigate = useNavigate();
|
||||
useNavToActivePathMapper('explore');
|
||||
const userId = mx.getUserId();
|
||||
const clientConfig = useClientConfig();
|
||||
const { servers: addedServers, addServer, removeServer } = useExploreServers();
|
||||
const userServer = userId ? getMxIdServer(userId) : undefined;
|
||||
const servers =
|
||||
clientConfig.featuredCommunities?.servers?.filter((server) => server !== userServer) ?? [];
|
||||
const featuredCommunityServers = clientConfig.featuredCommunities?.servers;
|
||||
const servers = useMemo(() => {
|
||||
const featuredServers =
|
||||
featuredCommunityServers?.filter((server) => server !== userServer) ?? [];
|
||||
const seen = new Set<string>();
|
||||
const merged: string[] = [];
|
||||
|
||||
[...featuredServers, ...addedServers].forEach((server) => {
|
||||
if (server === userServer) return;
|
||||
const key = server.toLowerCase();
|
||||
if (seen.has(key)) return;
|
||||
seen.add(key);
|
||||
merged.push(server);
|
||||
});
|
||||
|
||||
return merged;
|
||||
}, [featuredCommunityServers, addedServers, userServer]);
|
||||
|
||||
const featuredSelected = useExploreFeaturedSelected();
|
||||
const selectedServer = useExploreServer();
|
||||
|
||||
const isUserAddedServer = useCallback(
|
||||
(server: string) => addedServers.some((entry) => entry.toLowerCase() === server.toLowerCase()),
|
||||
[addedServers]
|
||||
);
|
||||
|
||||
const handleRemoveServer = useCallback(
|
||||
(server: string) => {
|
||||
removeServer(server)
|
||||
.then((removed) => {
|
||||
if (!removed) return;
|
||||
if (selectedServer?.toLowerCase() === server.toLowerCase()) {
|
||||
navigate(getExploreFeaturedPath());
|
||||
}
|
||||
})
|
||||
.catch(() => undefined);
|
||||
},
|
||||
[navigate, removeServer, selectedServer]
|
||||
);
|
||||
|
||||
const handleRemoveServerClick =
|
||||
(server: string): MouseEventHandler<HTMLButtonElement> =>
|
||||
(evt) => {
|
||||
evt.preventDefault();
|
||||
evt.stopPropagation();
|
||||
handleRemoveServer(server);
|
||||
};
|
||||
|
||||
const [roomSidebarWidth, setRoomSidebarWidth] = useSetting(settingsAtom, 'roomSidebarWidth');
|
||||
const [curWidth, setCurWidth] = useState(roomSidebarWidth);
|
||||
|
||||
@@ -301,12 +378,26 @@ export function Explore() {
|
||||
</Box>
|
||||
</NavItemContent>
|
||||
</NavLink>
|
||||
{!hideText && isUserAddedServer(server) && (
|
||||
<NavItemOptions>
|
||||
<IconButton
|
||||
size="300"
|
||||
variant="Critical"
|
||||
fill="None"
|
||||
radii="300"
|
||||
aria-label={`Remove ${server}`}
|
||||
onClick={handleRemoveServerClick(server)}
|
||||
>
|
||||
{menuIcon(Trash)}
|
||||
</IconButton>
|
||||
</NavItemOptions>
|
||||
)}
|
||||
</NavItem>
|
||||
))}
|
||||
</NavCategory>
|
||||
)}
|
||||
<Box direction="Column">
|
||||
<AddServer hideText={hideText} />
|
||||
<AddServer hideText={hideText} onAddServer={addServer} />
|
||||
</Box>
|
||||
</Box>
|
||||
</PageNavContent>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MouseEventHandler } from 'react';
|
||||
import type { MouseEventHandler, ComponentProps } from 'react';
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { Avatar, Box, Chip, Header, IconButton, Scroll, Text, config, toRem } from 'folds';
|
||||
import {
|
||||
@@ -11,7 +11,13 @@ import {
|
||||
sizedIcon,
|
||||
} from '$components/icons/phosphor';
|
||||
import { useSearchParams } from 'react-router-dom';
|
||||
import type { INotification, INotificationsResponse, IRoomEvent, Room } from '$types/matrix-sdk';
|
||||
import type {
|
||||
INotification,
|
||||
INotificationsResponse,
|
||||
IRoomEvent,
|
||||
MatrixEvent,
|
||||
Room,
|
||||
} from '$types/matrix-sdk';
|
||||
import type { IImageContent } from '$types/matrix/common';
|
||||
import { JoinRule, Method, RelationType, EventType } from '$types/matrix-sdk';
|
||||
import { useVirtualizer } from '@tanstack/react-virtual';
|
||||
@@ -46,6 +52,7 @@ import {
|
||||
Time,
|
||||
Username,
|
||||
UsernameBold,
|
||||
type RenderImageContentProps,
|
||||
} from '$components/message';
|
||||
import {
|
||||
factoryRenderLinkifyWithMention,
|
||||
@@ -196,6 +203,182 @@ const useNotificationTimeline = (
|
||||
return [notificationTimeline, loadTimeline, silentReloadTimeline];
|
||||
};
|
||||
|
||||
type NotificationRendererContext = {
|
||||
mx: ReturnType<typeof useMatrixClient>;
|
||||
room: Room;
|
||||
mediaAutoLoad?: boolean;
|
||||
urlPreview?: boolean;
|
||||
htmlReactParserOptions: HTMLReactParserOptions;
|
||||
linkifyOpts: LinkifyOpts;
|
||||
};
|
||||
|
||||
function NotificationLazyImage(props: ComponentProps<typeof Image>) {
|
||||
return <Image {...props} loading="lazy" />;
|
||||
}
|
||||
|
||||
function renderNotificationStickerImageContent(
|
||||
mediaAutoLoad: boolean | undefined,
|
||||
props: RenderImageContentProps
|
||||
) {
|
||||
return (
|
||||
<ImageContent
|
||||
{...props}
|
||||
autoPlay={mediaAutoLoad}
|
||||
renderImage={NotificationLazyImage}
|
||||
renderViewer={ImageViewer}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function renderNotificationRoomMessage(
|
||||
ctx: NotificationRendererContext,
|
||||
event: IRoomEvent,
|
||||
displayName: string,
|
||||
getContent: GetContentCallback
|
||||
) {
|
||||
if (event.unsigned?.redacted_because) {
|
||||
return <RedactedContent reason={event.unsigned?.redacted_because.content.reason} />;
|
||||
}
|
||||
const evtTimeline = ctx.room.getTimelineForEvent(event.event_id);
|
||||
const mEvent = evtTimeline?.getEvents().find((e) => e.getId() === event.event_id);
|
||||
return (
|
||||
<RenderMessageContent
|
||||
displayName={displayName}
|
||||
msgType={event.content.msgtype ?? ''}
|
||||
ts={event.origin_server_ts}
|
||||
getContent={getContent}
|
||||
mediaAutoLoad={ctx.mediaAutoLoad}
|
||||
urlPreview={ctx.urlPreview}
|
||||
htmlReactParserOptions={ctx.htmlReactParserOptions}
|
||||
linkifyOpts={ctx.linkifyOpts}
|
||||
outlineAttachment
|
||||
mx={ctx.mx}
|
||||
room={ctx.room}
|
||||
mEvent={mEvent}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function renderNotificationEncryptedDecrypted(
|
||||
ctx: NotificationRendererContext,
|
||||
evt: IRoomEvent,
|
||||
displayName: string,
|
||||
mEvent: MatrixEvent,
|
||||
evtTimeline: NonNullable<ReturnType<Room['getTimelineForEvent']>>
|
||||
) {
|
||||
if (mEvent.isRedacted()) return <RedactedContent />;
|
||||
if (mEvent.getType() === (EventType.Sticker as string)) {
|
||||
return (
|
||||
<MSticker
|
||||
content={mEvent.getContent()}
|
||||
renderImageContent={renderNotificationStickerImageContent.bind(null, ctx.mediaAutoLoad)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
if (mEvent.getType() === (EventType.RoomMessage as string)) {
|
||||
const editedEvent = getEditedEvent(evt.event_id, mEvent, evtTimeline.getTimelineSet());
|
||||
const getContent = (() =>
|
||||
editedEvent?.getContent()['m.new_content'] ?? mEvent.getContent()) as GetContentCallback;
|
||||
|
||||
return (
|
||||
<RenderMessageContent
|
||||
displayName={displayName}
|
||||
msgType={mEvent.getContent().msgtype ?? ''}
|
||||
ts={mEvent.getTs()}
|
||||
edited={!!editedEvent}
|
||||
getContent={getContent}
|
||||
mediaAutoLoad={ctx.mediaAutoLoad}
|
||||
urlPreview={ctx.urlPreview}
|
||||
htmlReactParserOptions={ctx.htmlReactParserOptions}
|
||||
linkifyOpts={ctx.linkifyOpts}
|
||||
mx={ctx.mx}
|
||||
room={ctx.room}
|
||||
mEvent={mEvent}
|
||||
/>
|
||||
);
|
||||
}
|
||||
if (mEvent.getType() === (EventType.RoomMessageEncrypted as string)) {
|
||||
return (
|
||||
<Text>
|
||||
<MessageNotDecryptedContent />
|
||||
</Text>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<Text>
|
||||
<MessageUnsupportedContent />
|
||||
</Text>
|
||||
);
|
||||
}
|
||||
|
||||
function renderNotificationEncrypted(
|
||||
ctx: NotificationRendererContext,
|
||||
evt: IRoomEvent,
|
||||
displayName: string
|
||||
) {
|
||||
const evtTimeline = ctx.room.getTimelineForEvent(evt.event_id);
|
||||
const mEvent = evtTimeline?.getEvents().find((e) => e.getId() === evt.event_id);
|
||||
|
||||
if (!mEvent || !evtTimeline) {
|
||||
return (
|
||||
<Box grow="Yes" direction="Column">
|
||||
<Text size="T400" priority="300">
|
||||
<code className={customHtmlCss.Code}>{evt.type}</code>
|
||||
{' event'}
|
||||
</Text>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<EncryptedContent mEvent={mEvent}>
|
||||
{renderNotificationEncryptedDecrypted.bind(null, ctx, evt, displayName, mEvent, evtTimeline)}
|
||||
</EncryptedContent>
|
||||
);
|
||||
}
|
||||
|
||||
function renderNotificationSticker(
|
||||
ctx: NotificationRendererContext,
|
||||
event: IRoomEvent,
|
||||
_displayName: string,
|
||||
getContent: GetContentCallback
|
||||
) {
|
||||
if (event.unsigned?.redacted_because) {
|
||||
return <RedactedContent reason={event.unsigned?.redacted_because.content.reason} />;
|
||||
}
|
||||
return (
|
||||
<MSticker
|
||||
content={getContent() as IImageContent}
|
||||
renderImageContent={renderNotificationStickerImageContent.bind(null, ctx.mediaAutoLoad)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function renderNotificationTombstone(_ctx: NotificationRendererContext, event: IRoomEvent) {
|
||||
const { content } = event;
|
||||
return (
|
||||
<Box grow="Yes" direction="Column">
|
||||
<Text size="T400" priority="300">
|
||||
Room Tombstone. {content.body}
|
||||
</Text>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
function renderNotificationFallback(_ctx: NotificationRendererContext, event: IRoomEvent) {
|
||||
if (event.unsigned?.redacted_because) {
|
||||
return <RedactedContent reason={event.unsigned?.redacted_because.content.reason} />;
|
||||
}
|
||||
return (
|
||||
<Box grow="Yes" direction="Column">
|
||||
<Text size="T400" priority="300">
|
||||
<code className={customHtmlCss.Code}>{event.type}</code>
|
||||
{' event'}
|
||||
</Text>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
type RoomNotificationsGroupProps = {
|
||||
room: Room;
|
||||
appBaseUrl: string;
|
||||
@@ -278,150 +461,32 @@ function RoomNotificationsGroupComp({
|
||||
]
|
||||
);
|
||||
|
||||
const rendererContext = useMemo<NotificationRendererContext>(
|
||||
() => ({
|
||||
mx,
|
||||
room,
|
||||
mediaAutoLoad,
|
||||
urlPreview,
|
||||
htmlReactParserOptions,
|
||||
linkifyOpts,
|
||||
}),
|
||||
[mx, room, mediaAutoLoad, urlPreview, htmlReactParserOptions, linkifyOpts]
|
||||
);
|
||||
|
||||
const matrixEventHandlers = useMemo(
|
||||
() => ({
|
||||
[EventType.RoomMessage]: renderNotificationRoomMessage.bind(null, rendererContext),
|
||||
[EventType.RoomMessageEncrypted]: renderNotificationEncrypted.bind(null, rendererContext),
|
||||
[EventType.Sticker]: renderNotificationSticker.bind(null, rendererContext),
|
||||
[EventType.RoomTombstone]: renderNotificationTombstone.bind(null, rendererContext),
|
||||
}),
|
||||
[rendererContext]
|
||||
);
|
||||
|
||||
const renderMatrixEvent = useMatrixEventRenderer<[IRoomEvent, string, GetContentCallback]>(
|
||||
{
|
||||
[EventType.RoomMessage]: (event, displayName, getContent) => {
|
||||
if (event.unsigned?.redacted_because) {
|
||||
return <RedactedContent reason={event.unsigned?.redacted_because.content.reason} />;
|
||||
}
|
||||
const evtTimeline = room.getTimelineForEvent(event.event_id);
|
||||
const mEvent = evtTimeline?.getEvents().find((e) => e.getId() === event.event_id);
|
||||
return (
|
||||
<RenderMessageContent
|
||||
displayName={displayName}
|
||||
msgType={event.content.msgtype ?? ''}
|
||||
ts={event.origin_server_ts}
|
||||
getContent={getContent}
|
||||
mediaAutoLoad={mediaAutoLoad}
|
||||
urlPreview={urlPreview}
|
||||
htmlReactParserOptions={htmlReactParserOptions}
|
||||
linkifyOpts={linkifyOpts}
|
||||
outlineAttachment
|
||||
mx={mx}
|
||||
room={room}
|
||||
mEvent={mEvent}
|
||||
/>
|
||||
);
|
||||
},
|
||||
[EventType.RoomMessageEncrypted]: (evt, displayName) => {
|
||||
const evtTimeline = room.getTimelineForEvent(evt.event_id);
|
||||
|
||||
const mEvent = evtTimeline?.getEvents().find((e) => e.getId() === evt.event_id);
|
||||
|
||||
if (!mEvent || !evtTimeline) {
|
||||
return (
|
||||
<Box grow="Yes" direction="Column">
|
||||
<Text size="T400" priority="300">
|
||||
<code className={customHtmlCss.Code}>{evt.type}</code>
|
||||
{' event'}
|
||||
</Text>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<EncryptedContent mEvent={mEvent}>
|
||||
{() => {
|
||||
if (mEvent.isRedacted()) return <RedactedContent />;
|
||||
if (mEvent.getType() === (EventType.Sticker as string))
|
||||
return (
|
||||
<MSticker
|
||||
content={mEvent.getContent()}
|
||||
renderImageContent={(props) => (
|
||||
<ImageContent
|
||||
{...props}
|
||||
autoPlay={mediaAutoLoad}
|
||||
renderImage={(p) => <Image {...p} loading="lazy" />}
|
||||
renderViewer={(p) => <ImageViewer {...p} />}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
);
|
||||
if (mEvent.getType() === (EventType.RoomMessage as string)) {
|
||||
const editedEvent = getEditedEvent(
|
||||
evt.event_id,
|
||||
mEvent,
|
||||
evtTimeline.getTimelineSet()
|
||||
);
|
||||
const getContent = (() =>
|
||||
editedEvent?.getContent()['m.new_content'] ??
|
||||
mEvent.getContent()) as GetContentCallback;
|
||||
|
||||
return (
|
||||
<RenderMessageContent
|
||||
displayName={displayName}
|
||||
msgType={mEvent.getContent().msgtype ?? ''}
|
||||
ts={mEvent.getTs()}
|
||||
edited={!!editedEvent}
|
||||
getContent={getContent}
|
||||
mediaAutoLoad={mediaAutoLoad}
|
||||
urlPreview={urlPreview}
|
||||
htmlReactParserOptions={htmlReactParserOptions}
|
||||
linkifyOpts={linkifyOpts}
|
||||
mx={mx}
|
||||
room={room}
|
||||
mEvent={mEvent}
|
||||
/>
|
||||
);
|
||||
}
|
||||
if (mEvent.getType() === (EventType.RoomMessageEncrypted as string))
|
||||
return (
|
||||
<Text>
|
||||
<MessageNotDecryptedContent />
|
||||
</Text>
|
||||
);
|
||||
return (
|
||||
<Text>
|
||||
<MessageUnsupportedContent />
|
||||
</Text>
|
||||
);
|
||||
}}
|
||||
</EncryptedContent>
|
||||
);
|
||||
},
|
||||
[EventType.Sticker]: (event, displayName, getContent) => {
|
||||
if (event.unsigned?.redacted_because) {
|
||||
return <RedactedContent reason={event.unsigned?.redacted_because.content.reason} />;
|
||||
}
|
||||
return (
|
||||
<MSticker
|
||||
content={getContent() as IImageContent}
|
||||
renderImageContent={(props) => (
|
||||
<ImageContent
|
||||
{...props}
|
||||
autoPlay={mediaAutoLoad}
|
||||
renderImage={(p) => <Image {...p} loading="lazy" />}
|
||||
renderViewer={(p) => <ImageViewer {...p} />}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
);
|
||||
},
|
||||
[EventType.RoomTombstone]: (event) => {
|
||||
const { content } = event;
|
||||
return (
|
||||
<Box grow="Yes" direction="Column">
|
||||
<Text size="T400" priority="300">
|
||||
Room Tombstone. {content.body}
|
||||
</Text>
|
||||
</Box>
|
||||
);
|
||||
},
|
||||
},
|
||||
matrixEventHandlers,
|
||||
undefined,
|
||||
(event) => {
|
||||
if (event.unsigned?.redacted_because) {
|
||||
return <RedactedContent reason={event.unsigned?.redacted_because.content.reason} />;
|
||||
}
|
||||
return (
|
||||
<Box grow="Yes" direction="Column">
|
||||
<Text size="T400" priority="300">
|
||||
<code className={customHtmlCss.Code}>{event.type}</code>
|
||||
{' event'}
|
||||
</Text>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
renderNotificationFallback.bind(null, rendererContext)
|
||||
);
|
||||
|
||||
const handleOpenClick: MouseEventHandler = (evt) => {
|
||||
|
||||
@@ -23,7 +23,7 @@ import { ScreenSize, useScreenSizeContext } from '$hooks/useScreenSize';
|
||||
import { useNavToActivePathAtom } from '$state/hooks/navToActivePath';
|
||||
import { markAsRead } from '$utils/notifications';
|
||||
import { stopPropagation } from '$utils/keyboard';
|
||||
import { Checks, menuIcon, getPhosphorSize, User } from '$components/icons/phosphor';
|
||||
import { Checks, menuIcon, getPhosphorIconSize, User } from '$components/icons/phosphor';
|
||||
import { settingsAtom } from '$state/settings';
|
||||
import { useSetting } from '$state/hooks/settings';
|
||||
import { useDirectRooms } from '$pages/client/direct/useDirectRooms';
|
||||
@@ -115,7 +115,10 @@ export function DirectTab() {
|
||||
onClick={handleDirectClick}
|
||||
onContextMenu={handleContextMenu}
|
||||
>
|
||||
<User size={getPhosphorSize().toolbar} weight={directSelected ? 'fill' : 'regular'} />
|
||||
<User
|
||||
size={getPhosphorIconSize('toolbar')}
|
||||
weight={directSelected ? 'fill' : 'regular'}
|
||||
/>
|
||||
</SidebarAvatar>
|
||||
)}
|
||||
</SidebarItemTooltip>
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useAtomValue } from 'jotai';
|
||||
import { SidebarAvatar, SidebarItem, SidebarItemTooltip } from '$components/sidebar';
|
||||
import { useExploreSelected } from '$hooks/router/useExploreSelected';
|
||||
import {
|
||||
getExploreFeaturedPath,
|
||||
getExplorePath,
|
||||
getExploreServerPath,
|
||||
joinPathComponent,
|
||||
} from '$pages/pathUtils';
|
||||
import { useClientConfig } from '$hooks/useClientConfig';
|
||||
import { useMatrixClient } from '$hooks/useMatrixClient';
|
||||
import { ScreenSize, useScreenSizeContext } from '$hooks/useScreenSize';
|
||||
import { useNavToActivePathAtom } from '$state/hooks/navToActivePath';
|
||||
import { getMxIdServer } from '$utils/mxIdHelper';
|
||||
import { Compass, getPhosphorIconSize } from '$components/icons/phosphor';
|
||||
|
||||
export function ExploreTab() {
|
||||
const mx = useMatrixClient();
|
||||
const screenSize = useScreenSizeContext();
|
||||
const clientConfig = useClientConfig();
|
||||
const navigate = useNavigate();
|
||||
const navToActivePath = useAtomValue(useNavToActivePathAtom());
|
||||
|
||||
const exploreSelected = useExploreSelected();
|
||||
|
||||
const handleExploreClick = () => {
|
||||
if (screenSize === ScreenSize.Mobile) {
|
||||
navigate(getExplorePath());
|
||||
return;
|
||||
}
|
||||
|
||||
const activePath = navToActivePath.get('explore');
|
||||
if (activePath) {
|
||||
navigate(joinPathComponent(activePath));
|
||||
return;
|
||||
}
|
||||
|
||||
if (clientConfig.featuredCommunities?.openAsDefault) {
|
||||
navigate(getExploreFeaturedPath());
|
||||
return;
|
||||
}
|
||||
const userId = mx.getUserId();
|
||||
const userServer = userId ? getMxIdServer(userId) : undefined;
|
||||
if (userServer) {
|
||||
navigate(getExploreServerPath(userServer));
|
||||
return;
|
||||
}
|
||||
navigate(getExplorePath());
|
||||
};
|
||||
|
||||
return (
|
||||
<SidebarItem active={exploreSelected}>
|
||||
<SidebarItemTooltip tooltip="Explore Community">
|
||||
{(triggerRef) => (
|
||||
<SidebarAvatar as="button" ref={triggerRef} outlined onClick={handleExploreClick}>
|
||||
<Compass
|
||||
size={getPhosphorIconSize('toolbar')}
|
||||
weight={exploreSelected ? 'fill' : 'regular'}
|
||||
/>
|
||||
</SidebarAvatar>
|
||||
)}
|
||||
</SidebarItemTooltip>
|
||||
</SidebarItem>
|
||||
);
|
||||
}
|
||||
@@ -27,7 +27,7 @@ import { stopPropagation } from '$utils/keyboard';
|
||||
import { useSetting } from '$state/hooks/settings';
|
||||
import { settingsAtom } from '$state/settings';
|
||||
import { useHomeRooms } from '$pages/client/home/useHomeRooms';
|
||||
import { Checks, House, menuIcon, getPhosphorSize } from '$components/icons/phosphor';
|
||||
import { Checks, House, menuIcon, getPhosphorIconSize } from '$components/icons/phosphor';
|
||||
|
||||
type HomeMenuProps = {
|
||||
requestClose: () => void;
|
||||
@@ -106,7 +106,10 @@ export function HomeTab() {
|
||||
onClick={handleHomeClick}
|
||||
onContextMenu={handleContextMenu}
|
||||
>
|
||||
<House size={getPhosphorSize().toolbar} weight={homeSelected ? 'fill' : 'regular'} />
|
||||
<House
|
||||
size={getPhosphorIconSize('toolbar')}
|
||||
weight={homeSelected ? 'fill' : 'regular'}
|
||||
/>
|
||||
</SidebarAvatar>
|
||||
)}
|
||||
</SidebarItemTooltip>
|
||||
|
||||
@@ -16,7 +16,7 @@ import { useInboxSelected } from '$hooks/router/useInbox';
|
||||
import { ScreenSize, useScreenSizeContext } from '$hooks/useScreenSize';
|
||||
import { useNavToActivePathAtom } from '$state/hooks/navToActivePath';
|
||||
import { useInviteCount } from '$hooks/useInviteCount';
|
||||
import { getPhosphorSize, Tray } from '$components/icons/phosphor';
|
||||
import { getPhosphorIconSize, Tray } from '$components/icons/phosphor';
|
||||
|
||||
export function InboxTab({isBottom}:{isBottom?: boolean}) {
|
||||
const screenSize = useScreenSizeContext();
|
||||
@@ -51,7 +51,7 @@ export function InboxTab({isBottom}:{isBottom?: boolean}) {
|
||||
onClick={handleInboxClick}
|
||||
size="300"
|
||||
>
|
||||
<Tray size={getPhosphorSize().inline} weight={inboxSelected ? 'fill' : 'regular'} />
|
||||
<Tray size={getPhosphorIconSize('inline')} weight={inboxSelected ? 'fill' : 'regular'} />
|
||||
</SidebarAvatar>
|
||||
)}
|
||||
</SidebarItemTooltip>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { useAtom } from 'jotai';
|
||||
import { SidebarAvatar, SidebarItem, SidebarItemTooltip } from '$components/sidebar';
|
||||
import { searchModalAtom } from '$state/searchModal';
|
||||
import { getPhosphorSize } from '$components/icons/phosphor';
|
||||
import { ListMagnifyingGlassIcon } from '@phosphor-icons/react';
|
||||
import { getPhosphorIconSize } from '$components/icons/phosphor';
|
||||
|
||||
export function SearchTab({isBottom}:{isBottom?: boolean}) {
|
||||
const [opened, setOpen] = useAtom(searchModalAtom);
|
||||
@@ -15,7 +15,7 @@ export function SearchTab({isBottom}:{isBottom?: boolean}) {
|
||||
{(triggerRef) => (
|
||||
<SidebarAvatar as="button" ref={triggerRef} outlined onClick={open} size="300">
|
||||
<ListMagnifyingGlassIcon
|
||||
size={getPhosphorSize().inline}
|
||||
size={getPhosphorIconSize('inline')}
|
||||
weight={opened ? 'fill' : 'regular'}
|
||||
/>
|
||||
</SidebarAvatar>
|
||||
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
} from '$hooks/useDeviceVerificationStatus';
|
||||
import { useCrossSigningActive } from '$hooks/useCrossSigning';
|
||||
import { useOpenSettings } from '$features/settings';
|
||||
import { getPhosphorSize, ShieldWarning } from '$components/icons/phosphor';
|
||||
import { getPhosphorIconSize, ShieldWarning } from '$components/icons/phosphor';
|
||||
import * as css from './UnverifiedTab.css';
|
||||
|
||||
function UnverifiedIndicator({isBottom}:{isBottom?: boolean}) {
|
||||
@@ -63,7 +63,7 @@ function UnverifiedIndicator({isBottom}:{isBottom?: boolean}) {
|
||||
style={{
|
||||
color: unverified ? color.Critical.Main : color.Warning.Main,
|
||||
}}
|
||||
size={getPhosphorSize().toolbar}
|
||||
size={getPhosphorIconSize('toolbar')}
|
||||
/>
|
||||
</SidebarAvatar>
|
||||
)}
|
||||
|
||||
@@ -108,7 +108,6 @@ import type { RoomBannerContent } from '$types/matrix-sdk-events';
|
||||
import { ModalWide } from '$styles/Modal.css';
|
||||
import { ImageViewer } from '$components/image-viewer';
|
||||
import * as css from './styles.css';
|
||||
import { ClientSideHoverFreeze } from '$components/ClientSideHoverFreeze';
|
||||
|
||||
const debugLog = createDebugLogger('Space');
|
||||
|
||||
@@ -373,14 +372,11 @@ function SpaceHeader({ hideText, mx }: { hideText?: boolean; mx: MatrixClient })
|
||||
{hasBanner && (
|
||||
<>
|
||||
<Box shrink="No" className={css.RoomCoverContainer} style={{ height: toRem(curHeight) }}>
|
||||
<ClientSideHoverFreeze src={bannerURI} className={css.RoomCover}>
|
||||
<img
|
||||
className={css.RoomCoverImage}
|
||||
src={bannerURI}
|
||||
alt={`${spaceName}'s banner`}
|
||||
draggable="false"
|
||||
role="button"
|
||||
tabIndex={0}
|
||||
<div className={css.RoomCover}>
|
||||
<button
|
||||
type="button"
|
||||
className={css.RoomCoverImageButton}
|
||||
data-no-button-motion
|
||||
aria-label={`View ${spaceName} banner`}
|
||||
onClick={() => setBannerViewerOpen(true)}
|
||||
onKeyDown={(e) => {
|
||||
@@ -389,7 +385,9 @@ function SpaceHeader({ hideText, mx }: { hideText?: boolean; mx: MatrixClient })
|
||||
setBannerViewerOpen(true);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
>
|
||||
<img className={css.RoomCoverImage} src={bannerURI} alt="" draggable="false" />
|
||||
</button>
|
||||
<SidebarResizer
|
||||
setCurWidth={setCurHeight}
|
||||
sidebarWidth={roomBannerHeight}
|
||||
@@ -400,7 +398,7 @@ function SpaceHeader({ hideText, mx }: { hideText?: boolean; mx: MatrixClient })
|
||||
maxValue={500}
|
||||
topSided
|
||||
/>
|
||||
</ClientSideHoverFreeze>
|
||||
</div>
|
||||
</Box>
|
||||
</>
|
||||
)}
|
||||
@@ -503,6 +501,12 @@ export function SpaceTombstone({ roomId, replacementRoomId }: SpaceTombstoneProp
|
||||
);
|
||||
}
|
||||
|
||||
const getCategoryPadding = (depth: number): string | undefined => {
|
||||
if (depth === 0) return undefined;
|
||||
if (depth === 1) return config.space.S400;
|
||||
return config.space.S0;
|
||||
};
|
||||
|
||||
export function Space() {
|
||||
const mx = useMatrixClient();
|
||||
const space = useSpace();
|
||||
@@ -840,12 +844,6 @@ export function Space() {
|
||||
const getToLink = (roomId: string) =>
|
||||
getSpaceRoomPath(spaceIdOrAlias, getCanonicalAliasOrRoomId(mx, roomId));
|
||||
|
||||
const getCategoryPadding = (depth: number): string | undefined => {
|
||||
if (depth === 0) return undefined;
|
||||
if (depth === 1) return config.space.S400;
|
||||
return config.space.S0;
|
||||
};
|
||||
|
||||
const navigate = useNavigate();
|
||||
const lastRoomId = useAtomValue(lastVisitedRoomIdAtom);
|
||||
|
||||
|
||||
@@ -35,8 +35,9 @@ export const RoomCoverContainer = style({
|
||||
export const RoomCover = style({
|
||||
height: '100%',
|
||||
width: '100%',
|
||||
objectFit: 'cover',
|
||||
objectPosition: 'center',
|
||||
position: 'relative',
|
||||
display: 'block',
|
||||
overflow: 'hidden',
|
||||
});
|
||||
|
||||
export const RoomCoverFallback = style({
|
||||
@@ -48,3 +49,13 @@ export const RoomCoverImage = style({
|
||||
objectFit: 'cover',
|
||||
width: '100%',
|
||||
});
|
||||
|
||||
export const RoomCoverImageButton = style({
|
||||
display: 'block',
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
padding: 0,
|
||||
border: 'none',
|
||||
background: 'none',
|
||||
cursor: 'pointer',
|
||||
});
|
||||
@@ -1,6 +1,8 @@
|
||||
import { pluginVersion } from '@arborium/arborium';
|
||||
|
||||
export type ArboriumThemeKind = 'light' | 'dark';
|
||||
|
||||
export const ARBORIUM_CDN_VERSION = '2.16.0';
|
||||
export const ARBORIUM_CDN_VERSION = pluginVersion;
|
||||
|
||||
const ARBORIUM_THEME_DEFINITIONS = [
|
||||
{ id: 'alabaster', label: 'Alabaster', kind: 'light' },
|
||||
@@ -33,6 +35,7 @@ const ARBORIUM_THEME_DEFINITIONS = [
|
||||
{ id: 'zenburn', label: 'Zenburn', kind: 'dark' },
|
||||
{ id: 'cobalt2', label: 'Cobalt2', kind: 'dark' },
|
||||
{ id: 'ef-melissa-dark', label: 'Ef Melissa Dark', kind: 'dark' },
|
||||
{ id: 'evergarden-fall', label: 'Evergarden Fall', kind: 'dark' },
|
||||
{ id: 'rustdoc-dark', label: 'Rustdoc Dark', kind: 'dark' },
|
||||
{ id: 'rustdoc-ayu', label: 'Rustdoc Ayu', kind: 'dark' },
|
||||
] as const;
|
||||
|
||||
@@ -4,6 +4,12 @@ import { markdownToHtml } from './markdownToHtml';
|
||||
import { htmlToMarkdown } from './htmlToMarkdown';
|
||||
import { injectDataMd } from './injectDataMd';
|
||||
|
||||
const roundtrip = (markdown: string) => {
|
||||
const html = markdownToHtml(markdown);
|
||||
const injected = injectDataMd(html);
|
||||
return htmlToMarkdown(injected);
|
||||
};
|
||||
|
||||
describe('bidirectional round-trip', () => {
|
||||
it('round-trips headings', () => {
|
||||
const markdown = '## Hello World';
|
||||
@@ -73,11 +79,6 @@ describe('bidirectional round-trip', () => {
|
||||
});
|
||||
|
||||
it('round-trips blockquotes', () => {
|
||||
const roundtrip = (markdown: string) => {
|
||||
const html = markdownToHtml(markdown);
|
||||
const injected = injectDataMd(html);
|
||||
return htmlToMarkdown(injected);
|
||||
};
|
||||
expect(roundtrip('> Quote text')).toBe('> Quote text');
|
||||
expect(roundtrip('> line one\n> line two')).toBe('> line one\n> line two');
|
||||
expect(roundtrip('> test\ntest')).toBe('> test\ntest');
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
getReactCustomHtmlParser,
|
||||
makeMentionCustomProps,
|
||||
renderMatrixMention,
|
||||
scaleSystemEmoji,
|
||||
} from './react-custom-html-parser';
|
||||
import { registerMatrixUriProtocol } from './matrix-uri';
|
||||
import { markdownToHtml } from './markdown/markdownToHtml';
|
||||
@@ -167,6 +168,19 @@ describe('react custom html parser', () => {
|
||||
expect(img).toHaveAttribute('height', '64');
|
||||
});
|
||||
|
||||
it.each(['', '', '', '🇩🇪', '🙂↔️'])(
|
||||
'wraps modern emoji text %s in emoticon markup',
|
||||
(emoji) => {
|
||||
const result = scaleSystemEmoji(emoji);
|
||||
expect(result).toHaveLength(1);
|
||||
expect(typeof result[0]).not.toBe('string');
|
||||
}
|
||||
);
|
||||
|
||||
it('does not wrap emojis inside urls', () => {
|
||||
expect(scaleSystemEmoji('https://example.com/')).toEqual(['https://example.com/']);
|
||||
});
|
||||
|
||||
it('renders same-origin raw settings links as mention-style chips through the factory link render path', () => {
|
||||
const renderLink = factoryRenderLinkifyWithMention(
|
||||
settingsLinkBaseUrl,
|
||||
|
||||
@@ -17,7 +17,6 @@ import {
|
||||
import type { IntermediateRepresentation, OptFn, Opts as LinkifyOpts } from 'linkifyjs';
|
||||
import Linkify from 'linkify-react';
|
||||
import type { ChildNode } from 'domhandler';
|
||||
|
||||
import * as css from '$styles/CustomHtml.css';
|
||||
import {
|
||||
getCanonicalAliasRoomId,
|
||||
@@ -26,8 +25,9 @@ import {
|
||||
mxcUrlToHttp,
|
||||
} from '$utils/matrix';
|
||||
import { getMemberDisplayName } from '$utils/room';
|
||||
import type { Nicknames } from '$state/nicknames';
|
||||
import { EMOJI_PATTERN, sanitizeForRegex, URL_NEG_LB } from '$utils/regex';
|
||||
import { type Nicknames } from '$state/nicknames';
|
||||
import { sanitizeForRegex, URL_REG } from '$utils/regex';
|
||||
import { splitEmojiText } from '$utils/emojiDetection';
|
||||
import { findAndReplace } from '$utils/findAndReplace';
|
||||
import { onEnterOrSpace } from '$utils/keyboard';
|
||||
import { copyToClipboard } from '$utils/dom';
|
||||
@@ -46,12 +46,9 @@ import {
|
||||
import { isRedundantMatrixUriAnchorText, parseMatrixUri, testMatrixUri } from './matrix-uri';
|
||||
import { getHexcodeForEmoji, getShortcodeFor } from './emoji';
|
||||
|
||||
const EMOJI_REG_G = new RegExp(`${URL_NEG_LB}(${EMOJI_PATTERN})`, 'g');
|
||||
|
||||
const shouldLinkifyDomText = (domNode: DOMText): boolean =>
|
||||
!(domNode.parent && 'name' in domNode.parent && domNode.parent.name === 'code') &&
|
||||
!(domNode.parent && 'name' in domNode.parent && domNode.parent.name === 'a');
|
||||
|
||||
export const LINKIFY_OPTS: LinkifyOpts = {
|
||||
attributes: {
|
||||
target: '_blank',
|
||||
@@ -348,19 +345,56 @@ export const factoryRenderLinkifyWithMention = (
|
||||
return renderLink;
|
||||
};
|
||||
|
||||
export const scaleSystemEmoji = (text: string): (string | JSX.Element)[] =>
|
||||
findAndReplace(
|
||||
text,
|
||||
EMOJI_REG_G,
|
||||
(match, pushIndex) => (
|
||||
<span key={`scaleSystemEmoji-${pushIndex}`} className={css.EmoticonBase}>
|
||||
<span className={css.Emoticon()} title={getShortcodeFor(getHexcodeForEmoji(match[0]))}>
|
||||
{match[0]}
|
||||
const scaleEmojiChunk = (text: string, output: (string | JSX.Element)[]) => {
|
||||
splitEmojiText(text).forEach((part) => {
|
||||
if (part.type === 'text') {
|
||||
output.push(part.value);
|
||||
return;
|
||||
}
|
||||
|
||||
output.push(
|
||||
<span key={`scaleSystemEmoji-${output.length}`} className={css.EmoticonBase}>
|
||||
<span className={css.Emoticon()} title={getShortcodeFor(getHexcodeForEmoji(part.value))}>
|
||||
{part.value}
|
||||
</span>
|
||||
</span>
|
||||
),
|
||||
(txt) => txt
|
||||
);
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
export const scaleSystemEmoji = (text: string): (string | JSX.Element)[] => {
|
||||
const parts: (string | JSX.Element)[] = [];
|
||||
const urlReg = new RegExp(URL_REG);
|
||||
let lastIndex = 0;
|
||||
|
||||
[...text.matchAll(urlReg)].forEach((match) => {
|
||||
const start = match.index ?? 0;
|
||||
scaleEmojiChunk(text.slice(lastIndex, start), parts);
|
||||
parts.push(match[0]);
|
||||
lastIndex = start + match[0].length;
|
||||
});
|
||||
|
||||
scaleEmojiChunk(text.slice(lastIndex), parts);
|
||||
|
||||
const normalized: (string | JSX.Element)[] = [];
|
||||
parts.forEach((part) => {
|
||||
if (typeof part !== 'string') {
|
||||
normalized.push(part);
|
||||
return;
|
||||
}
|
||||
|
||||
if (part === '') return;
|
||||
const previous = normalized.at(-1);
|
||||
if (typeof previous === 'string') {
|
||||
normalized[normalized.length - 1] = `${previous}${part}`;
|
||||
return;
|
||||
}
|
||||
|
||||
normalized.push(part);
|
||||
});
|
||||
|
||||
return normalized.length > 0 ? normalized : [''];
|
||||
};
|
||||
|
||||
export const makeHighlightRegex = (highlights: string[]): RegExp | undefined => {
|
||||
const pattern = highlights.map(sanitizeForRegex).join('|');
|
||||
@@ -387,27 +421,26 @@ export const highlightText = (
|
||||
);
|
||||
});
|
||||
|
||||
const extractTextFromNodes = (n: ChildNode[]): string => {
|
||||
let text = '';
|
||||
n.forEach((node) => {
|
||||
if ((node.type as unknown as string) === 'text') {
|
||||
text += (node as unknown as Text).data;
|
||||
} else if (node instanceof Element && node.children) {
|
||||
text += extractTextFromNodes(node.children);
|
||||
}
|
||||
});
|
||||
return text;
|
||||
};
|
||||
|
||||
/**
|
||||
* Recursively extracts and concatenates all text content from an array of ChildNode objects.
|
||||
*
|
||||
* @param {ChildNode[]} nodes - An array of ChildNode objects to extract text from.
|
||||
* @returns {string} The concatenated plain text content of all descendant text nodes.
|
||||
*/
|
||||
const extractTextFromChildren = (nodes: ChildNode[]): string => {
|
||||
const worker = (n: ChildNode[]): string => {
|
||||
let text = '';
|
||||
n.forEach((node) => {
|
||||
if ((node.type as unknown as string) === 'text') {
|
||||
text += (node as unknown as Text).data;
|
||||
} else if (node instanceof Element && node.children) {
|
||||
text += worker(node.children);
|
||||
}
|
||||
});
|
||||
return text;
|
||||
};
|
||||
|
||||
return worker(nodes).replace(/\n$/, '');
|
||||
};
|
||||
const extractTextFromChildren = (nodes: ChildNode[]): string =>
|
||||
extractTextFromNodes(nodes).replace(/\n$/, '');
|
||||
|
||||
const getLanguageFromClassName = (className?: string): string | undefined => {
|
||||
if (!className) return undefined;
|
||||
|
||||
@@ -129,6 +129,7 @@ export interface Settings {
|
||||
useInAppNotifications: boolean;
|
||||
useSystemNotifications: boolean;
|
||||
isNotificationSounds: boolean;
|
||||
backgroundNotificationSounds: boolean;
|
||||
showMessageContentInNotifications: boolean;
|
||||
showMessageContentInEncryptedNotifications: boolean;
|
||||
clearNotificationsOnRead: boolean;
|
||||
@@ -283,6 +284,7 @@ export const defaultSettings: Settings = {
|
||||
useInAppNotifications: mobileOrTablet(),
|
||||
useSystemNotifications: !mobileOrTablet(),
|
||||
isNotificationSounds: true,
|
||||
backgroundNotificationSounds: true,
|
||||
showMessageContentInNotifications: false,
|
||||
showMessageContentInEncryptedNotifications: false,
|
||||
clearNotificationsOnRead: false,
|
||||
|
||||
@@ -45,3 +45,11 @@ globalStyle(
|
||||
transform: 'none !important',
|
||||
}
|
||||
);
|
||||
|
||||
globalStyle(
|
||||
'button[data-no-button-motion], button[data-no-button-motion]:hover, button[data-no-button-motion]:active',
|
||||
{
|
||||
transform: 'none !important',
|
||||
transition: 'none !important',
|
||||
}
|
||||
);
|
||||
@@ -0,0 +1,44 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { isEmojiGrapheme, isJumboEmojiText, splitEmojiText } from './emojiDetection';
|
||||
|
||||
describe('isEmojiGrapheme', () => {
|
||||
it.each(['', '', '', '🇩🇪', '🙂↔️', '™️'])('matches emoji grapheme %s', (emoji) => {
|
||||
expect(isEmojiGrapheme(emoji)).toBe(true);
|
||||
});
|
||||
|
||||
it.each(['a', '12', 'http'])('does not match plain text segment %s', (value) => {
|
||||
expect(isEmojiGrapheme(value)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('splitEmojiText', () => {
|
||||
it('preserves newer emoji as standalone parts', () => {
|
||||
expect(splitEmojiText('ab')).toEqual([
|
||||
{ type: 'text', value: 'a' },
|
||||
{ type: 'emoji', value: '' },
|
||||
{ type: 'text', value: 'b' },
|
||||
]);
|
||||
});
|
||||
|
||||
it('keeps emoji sequences whole', () => {
|
||||
expect(splitEmojiText('🙂↔️')).toEqual([
|
||||
{ type: 'text', value: '' },
|
||||
{ type: 'emoji', value: '🙂↔️' },
|
||||
{ type: 'text', value: '' },
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isJumboEmojiText', () => {
|
||||
it.each(['', '', '', '🇩🇪', '🙂↔️'])('matches modern emoji sequence %s', (emoji) => {
|
||||
expect(isJumboEmojiText(emoji)).toBe(true);
|
||||
});
|
||||
|
||||
it.each(['123', 'hello', 'abc 123'])('does not match non-emoji text %s', (value) => {
|
||||
expect(isJumboEmojiText(value)).toBe(false);
|
||||
});
|
||||
|
||||
it('still matches shortcode-only content', () => {
|
||||
expect(isJumboEmojiText(':blobcat:')).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,88 @@
|
||||
/**
|
||||
* Emoji detection works on grapheme clusters, not raw code points.
|
||||
* Intl.Segmenter keeps ZWJ sequences, flags, and keycaps intact as single user-visible units.
|
||||
* Each grapheme is treated as emoji-like if it is a keycap sequence, an emoji forced by Variation Selector-16, or contains Emoji_Presentation, Extended_Pictographic, or Regional_Indicator.
|
||||
* This is intentionally broader than `\p{RGI_Emoji}` because browsers can lag on that property for newer emojis like ``.
|
||||
* The goal here is UI rendering, so broad emoji-like detection is more useful than strict Unicode interchange validation.
|
||||
*/
|
||||
|
||||
const graphemeSegmenter = new Intl.Segmenter(undefined, { granularity: 'grapheme' });
|
||||
|
||||
const SHORTCODE_TOKEN_REG = /^:[^:\s]+:/u;
|
||||
const EMOJI_GRAPHEME_REG =
|
||||
/[#*0-9]\uFE0F?\u20E3|\p{Emoji}\uFE0F|[\p{Emoji_Presentation}\p{Extended_Pictographic}\p{Regional_Indicator}]/u;
|
||||
|
||||
export type EmojiTextPart =
|
||||
| {
|
||||
type: 'text';
|
||||
value: string;
|
||||
}
|
||||
| {
|
||||
type: 'emoji';
|
||||
value: string;
|
||||
};
|
||||
|
||||
export const getFirstGrapheme = (text: string): string => {
|
||||
const first = graphemeSegmenter.segment(text)[Symbol.iterator]().next();
|
||||
return first.done ? '' : first.value.segment;
|
||||
};
|
||||
|
||||
export const isEmojiGrapheme = (segment: string): boolean => {
|
||||
if (!segment) return false;
|
||||
return EMOJI_GRAPHEME_REG.test(segment);
|
||||
};
|
||||
|
||||
export const splitEmojiText = (text: string): EmojiTextPart[] => {
|
||||
const parts: EmojiTextPart[] = [];
|
||||
let buffer = '';
|
||||
let foundEmoji = false;
|
||||
|
||||
[...graphemeSegmenter.segment(text)].forEach(({ segment }) => {
|
||||
if (isEmojiGrapheme(segment)) {
|
||||
foundEmoji = true;
|
||||
parts.push({ type: 'text', value: buffer });
|
||||
buffer = '';
|
||||
parts.push({ type: 'emoji', value: segment });
|
||||
} else {
|
||||
buffer += segment;
|
||||
}
|
||||
});
|
||||
|
||||
if (!foundEmoji) {
|
||||
return [{ type: 'text', value: buffer }];
|
||||
}
|
||||
|
||||
parts.push({ type: 'text', value: buffer });
|
||||
return parts;
|
||||
};
|
||||
|
||||
export const isJumboEmojiText = (text: string, maxTokens = 10): boolean => {
|
||||
if (!text) return false;
|
||||
|
||||
let tokenCount = 0;
|
||||
let index = 0;
|
||||
|
||||
while (index < text.length) {
|
||||
const remainder = text.slice(index);
|
||||
const whitespaceMatch = /^\s+/u.exec(remainder);
|
||||
if (whitespaceMatch) {
|
||||
index += whitespaceMatch[0].length;
|
||||
} else {
|
||||
const shortcodeMatch = SHORTCODE_TOKEN_REG.exec(remainder);
|
||||
if (shortcodeMatch) {
|
||||
tokenCount += 1;
|
||||
if (tokenCount > maxTokens) return false;
|
||||
index += shortcodeMatch[0].length;
|
||||
} else {
|
||||
const grapheme = getFirstGrapheme(remainder);
|
||||
if (!isEmojiGrapheme(grapheme)) return false;
|
||||
|
||||
tokenCount += 1;
|
||||
if (tokenCount > maxTokens) return false;
|
||||
index += grapheme.length;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return tokenCount > 0;
|
||||
};
|
||||
@@ -60,6 +60,27 @@ describe('formatCompactNumber', () => {
|
||||
expect(format).toHaveBeenCalledWith(1_250_000);
|
||||
});
|
||||
|
||||
it('filters invalid locale tags like c and falls back to en', () => {
|
||||
const format = vi.fn<(num: number) => string>().mockReturnValue('formatted');
|
||||
const numberFormat = vi
|
||||
.spyOn(Intl, 'NumberFormat')
|
||||
.mockImplementation(function MockNumberFormat(locales: Intl.LocalesArgument) {
|
||||
const list = Array.isArray(locales) ? locales : [locales];
|
||||
if (list.some((locale) => locale === 'c')) {
|
||||
throw new RangeError('Invalid language tag: c');
|
||||
}
|
||||
return {
|
||||
format,
|
||||
} as unknown as Intl.NumberFormat;
|
||||
} as typeof Intl.NumberFormat);
|
||||
|
||||
expect(formatCompactNumber(1_500, { locales: ['c', 'en'] })).toBe('formatted');
|
||||
expect(numberFormat).toHaveBeenCalledWith(['en'], {
|
||||
notation: 'compact',
|
||||
maximumFractionDigits: 1,
|
||||
});
|
||||
});
|
||||
|
||||
it('uses Intl compact notation for formatted output', () => {
|
||||
const expected = new Intl.NumberFormat(['fr-FR'], {
|
||||
notation: 'compact',
|
||||
|
||||
@@ -4,9 +4,30 @@ type FormatCompactNumberOptions = {
|
||||
};
|
||||
|
||||
const DEFAULT_MAXIMUM_FRACTION_DIGITS = 1;
|
||||
const FALLBACK_LOCALES: Intl.LocalesArgument = ['en'];
|
||||
|
||||
const isValidLocale = (locale: string): boolean => {
|
||||
try {
|
||||
Intl.NumberFormat(locale);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
const sanitizeLocales = (locales: Intl.LocalesArgument | undefined): Intl.LocalesArgument => {
|
||||
if (locales === undefined) return FALLBACK_LOCALES;
|
||||
|
||||
const list = Array.isArray(locales) ? locales : [locales];
|
||||
const valid = list.filter(
|
||||
(locale): locale is string => typeof locale === 'string' && isValidLocale(locale)
|
||||
);
|
||||
|
||||
return valid.length > 0 ? valid : FALLBACK_LOCALES;
|
||||
};
|
||||
|
||||
const getDefaultLocales = (): Intl.LocalesArgument | undefined =>
|
||||
typeof navigator === 'undefined' ? undefined : navigator.languages;
|
||||
typeof navigator === 'undefined' ? undefined : sanitizeLocales(navigator.languages);
|
||||
|
||||
export function formatCompactNumber(
|
||||
value: number,
|
||||
@@ -15,7 +36,7 @@ export function formatCompactNumber(
|
||||
maximumFractionDigits = DEFAULT_MAXIMUM_FRACTION_DIGITS,
|
||||
}: FormatCompactNumberOptions = {}
|
||||
): string {
|
||||
return new Intl.NumberFormat(locales, {
|
||||
return new Intl.NumberFormat(sanitizeLocales(locales), {
|
||||
notation: 'compact',
|
||||
maximumFractionDigits,
|
||||
}).format(value);
|
||||
|
||||
@@ -10,17 +10,3 @@ export const URL_REG = new RegExp(HTTP_URL_PATTERN, 'g');
|
||||
|
||||
export const EMAIL_REGEX =
|
||||
/^(([^<>()[\]\\.,;:\s@\\"]+(\.[^<>()[\]\\.,;:\s@\\"]+)*)|(\\".+\\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
||||
|
||||
export const URL_NEG_LB = '(?<!(https?|ftp|mailto|magnet):\\/\\/\\S*)';
|
||||
|
||||
// https://en.wikipedia.org/wiki/Variation_Selectors_(Unicode_block)
|
||||
export const VARIATION_SELECTOR_PATTERN = '[\uFE00-\uFE0F]';
|
||||
|
||||
// https://github.com/mathiasbynens/emoji-regex
|
||||
export const EMOJI_PATTERN = `[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC
Line truncated
|
||||
|
||||
// Thumbs up emoji found to have Variation Selector 16 at the end
|
||||
// so included variation selector pattern in regex
|
||||
export const JUMBO_EMOJI_REG = new RegExp(
|
||||
`^(((${EMOJI_PATTERN})|(:.+?:))(${VARIATION_SELECTOR_PATTERN}|\\s)*){1,10}$`
|
||||
);
|
||||
@@ -0,0 +1,168 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { EventType, RelationType } from '$types/matrix-sdk';
|
||||
import type { EventTimelineSet, MatrixEvent, Room } from '$types/matrix-sdk';
|
||||
import { extractReplyDraftBody, findRoomEventById, resolveReplyDraftTarget } from './room';
|
||||
|
||||
/* oxlint-disable typescript/no-explicit-any */
|
||||
|
||||
const createMessageEvent = (id: string, body: string, sender = '@alice:example.com') =>
|
||||
({
|
||||
getId: () => id,
|
||||
getType: () => EventType.RoomMessage,
|
||||
getSender: () => sender,
|
||||
getContent: () => ({ body, msgtype: 'm.text' }),
|
||||
getWireContent: () => ({ body, msgtype: 'm.text' }),
|
||||
getRelation: () => undefined,
|
||||
isRedaction: () => false,
|
||||
isRedacted: () => false,
|
||||
}) as unknown as MatrixEvent;
|
||||
|
||||
const createReactionEvent = (id: string, targetId: string) =>
|
||||
({
|
||||
getId: () => id,
|
||||
getType: () => EventType.Reaction,
|
||||
getSender: () => '@bob:example.com',
|
||||
getContent: () => ({
|
||||
'm.relates_to': {
|
||||
rel_type: RelationType.Annotation,
|
||||
event_id: targetId,
|
||||
key: '👍',
|
||||
},
|
||||
}),
|
||||
getWireContent: () => ({
|
||||
'm.relates_to': {
|
||||
rel_type: RelationType.Annotation,
|
||||
event_id: targetId,
|
||||
key: '👍',
|
||||
},
|
||||
}),
|
||||
getRelation: () => ({
|
||||
rel_type: RelationType.Annotation,
|
||||
event_id: targetId,
|
||||
key: '👍',
|
||||
}),
|
||||
isRedaction: () => false,
|
||||
isRedacted: () => false,
|
||||
}) as unknown as MatrixEvent;
|
||||
|
||||
const createEditEvent = (id: string, targetId: string, newBody: string) =>
|
||||
({
|
||||
getId: () => id,
|
||||
getType: () => EventType.RoomMessage,
|
||||
getSender: () => '@alice:example.com',
|
||||
getContent: () => ({
|
||||
'm.new_content': { body: newBody, msgtype: 'm.text' },
|
||||
'm.relates_to': {
|
||||
rel_type: RelationType.Replace,
|
||||
event_id: targetId,
|
||||
},
|
||||
}),
|
||||
getWireContent: () => ({
|
||||
'm.new_content': { body: newBody, msgtype: 'm.text' },
|
||||
'm.relates_to': {
|
||||
rel_type: RelationType.Replace,
|
||||
event_id: targetId,
|
||||
},
|
||||
}),
|
||||
getRelation: () => ({
|
||||
rel_type: RelationType.Replace,
|
||||
event_id: targetId,
|
||||
}),
|
||||
isRedaction: () => false,
|
||||
isRedacted: () => false,
|
||||
}) as unknown as MatrixEvent;
|
||||
|
||||
const createTimelineSet = (
|
||||
events: Record<string, MatrixEvent>,
|
||||
relations: Record<string, MatrixEvent[]> = {}
|
||||
) => {
|
||||
const parents = Object.values(events).filter(
|
||||
(event) => event.getType() === EventType.RoomMessage
|
||||
);
|
||||
|
||||
return {
|
||||
findEventById: (id: string) => events[id],
|
||||
getTimelines: () => [{ getEvents: () => parents }],
|
||||
relations: {
|
||||
getChildEventsForEvent: (eventId: string, relType: string, eventType: string) => {
|
||||
const key = `${eventId}:${relType}:${eventType}`;
|
||||
const relEvents = relations[key] ?? [];
|
||||
return {
|
||||
getRelations: () => relEvents,
|
||||
};
|
||||
},
|
||||
},
|
||||
} as unknown as EventTimelineSet;
|
||||
};
|
||||
|
||||
describe('findRoomEventById', () => {
|
||||
it('finds relation-only events via timeline relations', () => {
|
||||
const message = createMessageEvent('$msg', 'hello');
|
||||
const reaction = createReactionEvent('$reaction', '$msg');
|
||||
const timelineSet = createTimelineSet(
|
||||
{ $msg: message },
|
||||
{
|
||||
[`$msg:${RelationType.Annotation}:${EventType.Reaction}`]: [reaction],
|
||||
}
|
||||
);
|
||||
|
||||
const room = {
|
||||
findEventById: () => undefined,
|
||||
getUnfilteredTimelineSet: () => timelineSet,
|
||||
} as unknown as Room;
|
||||
|
||||
expect(findRoomEventById(room, '$reaction', timelineSet)?.getId()).toBe('$reaction');
|
||||
});
|
||||
});
|
||||
|
||||
describe('resolveReplyDraftTarget', () => {
|
||||
it('keeps reaction replies on the reaction event', () => {
|
||||
const message = createMessageEvent('$msg', 'hello there');
|
||||
const reaction = createReactionEvent('$reaction', '$msg');
|
||||
const timelineSet = createTimelineSet(
|
||||
{ $msg: message },
|
||||
{
|
||||
[`$msg:${RelationType.Annotation}:${EventType.Reaction}`]: [reaction],
|
||||
}
|
||||
);
|
||||
|
||||
const room = {
|
||||
findEventById: (id: string) => (id === '$msg' ? message : undefined),
|
||||
getUnfilteredTimelineSet: () => timelineSet,
|
||||
} as unknown as Room;
|
||||
|
||||
const resolved = resolveReplyDraftTarget(room, '$reaction', timelineSet);
|
||||
expect(resolved?.eventId).toBe('$reaction');
|
||||
expect(resolved?.replyEvt.getId()).toBe('$reaction');
|
||||
|
||||
const { body } = extractReplyDraftBody(resolved!.replyEvt, timelineSet);
|
||||
expect(body).toBe('');
|
||||
});
|
||||
|
||||
it('keeps edit replies on the edit event with edited body text', () => {
|
||||
const message = createMessageEvent('$msg', 'hello there');
|
||||
const edit = createEditEvent('$edit', '$msg', 'hello edited');
|
||||
const timelineSet = createTimelineSet(
|
||||
{ $msg: message },
|
||||
{
|
||||
[`$msg:${RelationType.Replace}:${EventType.RoomMessage}`]: [edit],
|
||||
}
|
||||
);
|
||||
|
||||
const room = {
|
||||
findEventById: (id: string) => {
|
||||
if (id === '$msg') return message;
|
||||
if (id === '$edit') return edit;
|
||||
return undefined;
|
||||
},
|
||||
getUnfilteredTimelineSet: () => timelineSet,
|
||||
} as unknown as Room;
|
||||
|
||||
const resolved = resolveReplyDraftTarget(room, '$edit', timelineSet);
|
||||
expect(resolved?.eventId).toBe('$edit');
|
||||
expect(resolved?.replyEvt.getId()).toBe('$edit');
|
||||
|
||||
const { body } = extractReplyDraftBody(resolved!.replyEvt, timelineSet);
|
||||
expect(body).toBe('hello edited');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,138 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { EventType, KnownMembership, RoomType } from '$types/matrix-sdk';
|
||||
import type { MatrixClient, MatrixEvent, Room } from '$types/matrix-sdk';
|
||||
import { getJoinedSpaceChildrenLeaveOrder, getJoinedSpaceChildrenSummary } from './room';
|
||||
|
||||
/* oxlint-disable typescript/no-explicit-any */
|
||||
|
||||
const SPACE = '!space:example.com';
|
||||
const SUBSPACE = '!subspace:example.com';
|
||||
const ROOM_1 = '!room1:example.com';
|
||||
const ROOM_2 = '!room2:example.com';
|
||||
const TOMBSTONED = '!old:example.com';
|
||||
|
||||
const createSpaceChildEvent = (childId: string) =>
|
||||
({
|
||||
getType: () => EventType.SpaceChild,
|
||||
getStateKey: () => childId,
|
||||
getContent: () => ({ via: [] }),
|
||||
}) as unknown as MatrixEvent;
|
||||
|
||||
const createRoom = (
|
||||
roomId: string,
|
||||
options: {
|
||||
isSpace?: boolean;
|
||||
membership?: string;
|
||||
tombstoned?: boolean;
|
||||
children?: string[];
|
||||
} = {}
|
||||
): Room => {
|
||||
const {
|
||||
isSpace = false,
|
||||
membership = KnownMembership.Join,
|
||||
tombstoned = false,
|
||||
children = [],
|
||||
} = options;
|
||||
|
||||
const stateEvents: MatrixEvent[] = [
|
||||
{
|
||||
getType: () => EventType.RoomCreate,
|
||||
getStateKey: () => '',
|
||||
getContent: () => ({ type: isSpace ? RoomType.Space : undefined }),
|
||||
} as unknown as MatrixEvent,
|
||||
...children.map(createSpaceChildEvent),
|
||||
];
|
||||
|
||||
if (tombstoned) {
|
||||
stateEvents.push({
|
||||
getType: () => EventType.RoomTombstone,
|
||||
getStateKey: () => '',
|
||||
getContent: () => ({ body: 'Upgraded', replacement_room: '!new:example.com' }),
|
||||
} as unknown as MatrixEvent);
|
||||
}
|
||||
|
||||
return {
|
||||
roomId,
|
||||
getMyMembership: () => membership,
|
||||
isSpaceRoom: () => isSpace,
|
||||
getLiveTimeline: () => ({
|
||||
getState: () => ({
|
||||
getStateEvents: (eventType: string, stateKey?: string) => {
|
||||
const events = stateEvents.filter((event) => event.getType() === eventType);
|
||||
if (stateKey !== undefined) {
|
||||
return events.find((event) => event.getStateKey?.() === stateKey);
|
||||
}
|
||||
return events;
|
||||
},
|
||||
}),
|
||||
}),
|
||||
} as unknown as Room;
|
||||
};
|
||||
|
||||
const createClient = (rooms: Record<string, Room>): MatrixClient =>
|
||||
({
|
||||
getRoom: (roomId: string) => rooms[roomId],
|
||||
}) as unknown as MatrixClient;
|
||||
|
||||
describe('getJoinedSpaceChildrenLeaveOrder', () => {
|
||||
it('returns only direct rooms for a flat space', () => {
|
||||
const mx = createClient({
|
||||
[SPACE]: createRoom(SPACE, { isSpace: true, children: [ROOM_1, ROOM_2] }),
|
||||
[ROOM_1]: createRoom(ROOM_1),
|
||||
[ROOM_2]: createRoom(ROOM_2),
|
||||
});
|
||||
|
||||
expect(getJoinedSpaceChildrenLeaveOrder(mx, SPACE)).toEqual([ROOM_1, ROOM_2]);
|
||||
});
|
||||
|
||||
it('does not include the root space itself', () => {
|
||||
const mx = createClient({
|
||||
[SPACE]: createRoom(SPACE, { isSpace: true, children: [SPACE, ROOM_1] }),
|
||||
[ROOM_1]: createRoom(ROOM_1),
|
||||
});
|
||||
|
||||
expect(getJoinedSpaceChildrenLeaveOrder(mx, SPACE)).toEqual([ROOM_1]);
|
||||
});
|
||||
|
||||
it('includes nested rooms and subspaces without counting the root space', () => {
|
||||
const mx = createClient({
|
||||
[SPACE]: createRoom(SPACE, { isSpace: true, children: [SUBSPACE] }),
|
||||
[SUBSPACE]: createRoom(SUBSPACE, { isSpace: true, children: [ROOM_1, ROOM_2] }),
|
||||
[ROOM_1]: createRoom(ROOM_1),
|
||||
[ROOM_2]: createRoom(ROOM_2),
|
||||
});
|
||||
|
||||
expect(getJoinedSpaceChildrenLeaveOrder(mx, SPACE)).toEqual([ROOM_1, ROOM_2, SUBSPACE]);
|
||||
});
|
||||
|
||||
it('skips tombstoned rooms', () => {
|
||||
const mx = createClient({
|
||||
[SPACE]: createRoom(SPACE, {
|
||||
isSpace: true,
|
||||
children: [ROOM_1, ROOM_2, TOMBSTONED],
|
||||
}),
|
||||
[ROOM_1]: createRoom(ROOM_1),
|
||||
[ROOM_2]: createRoom(ROOM_2),
|
||||
[TOMBSTONED]: createRoom(TOMBSTONED, { tombstoned: true }),
|
||||
});
|
||||
|
||||
expect(getJoinedSpaceChildrenLeaveOrder(mx, SPACE)).toEqual([ROOM_1, ROOM_2]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getJoinedSpaceChildrenSummary', () => {
|
||||
it('separates room and subspace counts', () => {
|
||||
const mx = createClient({
|
||||
[SPACE]: createRoom(SPACE, { isSpace: true, children: [SUBSPACE] }),
|
||||
[SUBSPACE]: createRoom(SUBSPACE, { isSpace: true, children: [ROOM_1, ROOM_2] }),
|
||||
[ROOM_1]: createRoom(ROOM_1),
|
||||
[ROOM_2]: createRoom(ROOM_2),
|
||||
});
|
||||
|
||||
expect(getJoinedSpaceChildrenSummary(mx, SPACE)).toEqual({
|
||||
leaveOrder: [ROOM_1, ROOM_2, SUBSPACE],
|
||||
roomCount: 2,
|
||||
subspaceCount: 1,
|
||||
});
|
||||
});
|
||||
});
|
||||
+172
-8
@@ -145,6 +145,80 @@ export const getSpaceChildren = (room: Room) =>
|
||||
return filtered;
|
||||
}, []);
|
||||
|
||||
export const getJoinedSpaceChildrenLeaveOrder = (
|
||||
mx: MatrixClient,
|
||||
rootSpaceId: string
|
||||
): string[] => {
|
||||
const leaveOrder: string[] = [];
|
||||
const visited = new Set<string>();
|
||||
|
||||
const isJoinedChild = (room: Room): boolean =>
|
||||
room.getMyMembership() === (KnownMembership.Join as string) &&
|
||||
!getStateEvent(room, EventType.RoomTombstone);
|
||||
|
||||
const visitSpace = (spaceId: string) => {
|
||||
if (visited.has(spaceId)) return;
|
||||
visited.add(spaceId);
|
||||
|
||||
const space = mx.getRoom(spaceId);
|
||||
if (!space || !isJoinedChild(space)) return;
|
||||
|
||||
getSpaceChildren(space).forEach((childId) => {
|
||||
if (visited.has(childId)) return;
|
||||
|
||||
const child = mx.getRoom(childId);
|
||||
if (!child || !isJoinedChild(child)) return;
|
||||
|
||||
if (child.isSpaceRoom()) {
|
||||
visitSpace(childId);
|
||||
return;
|
||||
}
|
||||
|
||||
visited.add(childId);
|
||||
leaveOrder.push(childId);
|
||||
});
|
||||
|
||||
if (spaceId !== rootSpaceId) {
|
||||
leaveOrder.push(spaceId);
|
||||
}
|
||||
};
|
||||
|
||||
visitSpace(rootSpaceId);
|
||||
|
||||
return leaveOrder.filter((id) => id !== rootSpaceId);
|
||||
};
|
||||
|
||||
export type JoinedSpaceChildrenSummary = {
|
||||
leaveOrder: string[];
|
||||
roomCount: number;
|
||||
subspaceCount: number;
|
||||
};
|
||||
|
||||
export const getJoinedSpaceChildrenSummary = (
|
||||
mx: MatrixClient,
|
||||
rootSpaceId: string
|
||||
): JoinedSpaceChildrenSummary => {
|
||||
const leaveOrder = getJoinedSpaceChildrenLeaveOrder(mx, rootSpaceId);
|
||||
let roomCount = 0;
|
||||
let subspaceCount = 0;
|
||||
|
||||
leaveOrder.forEach((id) => {
|
||||
const room = mx.getRoom(id);
|
||||
if (room?.isSpaceRoom()) {
|
||||
subspaceCount += 1;
|
||||
} else {
|
||||
roomCount += 1;
|
||||
}
|
||||
});
|
||||
|
||||
return { leaveOrder, roomCount, subspaceCount };
|
||||
};
|
||||
|
||||
export const getRecursiveSpaceLeaveOrder = (mx: MatrixClient, rootSpaceId: string): string[] => [
|
||||
...getJoinedSpaceChildrenLeaveOrder(mx, rootSpaceId),
|
||||
rootSpaceId,
|
||||
];
|
||||
|
||||
export const mapParentWithChildren = (
|
||||
roomToParents: RoomToParents,
|
||||
roomId: string,
|
||||
@@ -791,20 +865,20 @@ export const shouldShowRedactionTimelineEvent = (
|
||||
return hiddenEventRedactionTimeline;
|
||||
};
|
||||
|
||||
const readReplaceTargetId = (
|
||||
relatesTo: { rel_type?: string; event_id?: string } | undefined
|
||||
): string | undefined => {
|
||||
if (relatesTo?.rel_type !== (RelationType.Replace as string)) return undefined;
|
||||
const eventId = relatesTo.event_id;
|
||||
return typeof eventId === 'string' && eventId.length > 0 ? eventId : undefined;
|
||||
};
|
||||
|
||||
export const getEditTargetId = (editEvent: MatrixEvent): string | undefined => {
|
||||
const relationEventId = editEvent.getRelation()?.event_id;
|
||||
if (typeof relationEventId === 'string' && relationEventId.length > 0) {
|
||||
return relationEventId;
|
||||
}
|
||||
|
||||
const readReplaceTargetId = (
|
||||
relatesTo: { rel_type?: string; event_id?: string } | undefined
|
||||
): string | undefined => {
|
||||
if (relatesTo?.rel_type !== (RelationType.Replace as string)) return undefined;
|
||||
const eventId = relatesTo.event_id;
|
||||
return typeof eventId === 'string' && eventId.length > 0 ? eventId : undefined;
|
||||
};
|
||||
|
||||
const content = editEvent.getContent();
|
||||
const fromContent = readReplaceTargetId(
|
||||
content['m.relates_to'] as { rel_type?: string; event_id?: string } | undefined
|
||||
@@ -1032,6 +1106,96 @@ export const unwrapRelationJumpTarget = (room: Room, eventId: string, maxHops =
|
||||
return current;
|
||||
};
|
||||
|
||||
const findRelationChildEvent = (
|
||||
timelineSet: EventTimelineSet,
|
||||
eventId: string
|
||||
): MatrixEvent | undefined => {
|
||||
for (const timeline of timelineSet.getTimelines()) {
|
||||
for (const parent of timeline.getEvents()) {
|
||||
const parentId = parent.getId();
|
||||
if (!parentId) continue;
|
||||
|
||||
const reactionRelations = getEventReactions(timelineSet, parentId);
|
||||
if (reactionRelations) {
|
||||
const reaction = reactionRelations
|
||||
.getRelations()
|
||||
.find((candidate) => candidate.getId() === eventId);
|
||||
if (reaction) return reaction;
|
||||
}
|
||||
|
||||
const editRelations = getEventEdits(timelineSet, parentId, parent.getType());
|
||||
if (editRelations) {
|
||||
const edit = editRelations
|
||||
.getRelations()
|
||||
.find((candidate) => candidate.getId() === eventId);
|
||||
if (edit) return edit;
|
||||
}
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
|
||||
export const findRoomEventById = (
|
||||
room: Room,
|
||||
eventId: string,
|
||||
timelineSet?: EventTimelineSet
|
||||
): MatrixEvent | undefined => {
|
||||
const set = timelineSet ?? room.getUnfilteredTimelineSet();
|
||||
return (
|
||||
set.findEventById(eventId) ??
|
||||
room.findEventById(eventId) ??
|
||||
findRelationChildEvent(set, eventId)
|
||||
);
|
||||
};
|
||||
|
||||
export type ResolvedReplyDraftTarget = {
|
||||
eventId: string;
|
||||
replyEvt: MatrixEvent;
|
||||
};
|
||||
|
||||
export const extractReplyDraftBody = (
|
||||
replyEvt: MatrixEvent,
|
||||
timelineSet: EventTimelineSet
|
||||
): { body: string; formattedBody: string } => {
|
||||
const replyId = replyEvt.getId();
|
||||
const editedReply =
|
||||
replyId !== undefined && !isEditEvent(replyEvt)
|
||||
? getEditedEvent(replyId, replyEvt, timelineSet)
|
||||
: undefined;
|
||||
const editedNewContent = editedReply?.getContent()['m.new_content'];
|
||||
const content = (editedNewContent ?? replyEvt.getContent()) as Record<string, unknown>;
|
||||
const { body, formatted_body: formattedBody } = content;
|
||||
const msc1767body = content['m.text'];
|
||||
|
||||
const resolvedBody =
|
||||
(typeof body === 'string' ? body : undefined) ??
|
||||
(typeof msc1767body === 'string'
|
||||
? msc1767body
|
||||
: (msc1767body as { body?: string } | undefined)?.body) ??
|
||||
getMessageVersionBody(replyEvt) ??
|
||||
'';
|
||||
|
||||
return {
|
||||
body: resolvedBody,
|
||||
formattedBody: typeof formattedBody === 'string' ? formattedBody : '',
|
||||
};
|
||||
};
|
||||
|
||||
export const resolveReplyDraftTarget = (
|
||||
room: Room,
|
||||
clickedEventId: string,
|
||||
timelineSet?: EventTimelineSet
|
||||
): ResolvedReplyDraftTarget | undefined => {
|
||||
const set = timelineSet ?? room.getUnfilteredTimelineSet();
|
||||
const replyEvt = findRoomEventById(room, clickedEventId, set);
|
||||
if (!replyEvt) return undefined;
|
||||
|
||||
const eventId = replyEvt.getId();
|
||||
if (!eventId) return undefined;
|
||||
|
||||
return { eventId, replyEvt };
|
||||
};
|
||||
|
||||
export const getMentionContent = (userIds: string[], room: boolean): IMentions => {
|
||||
const mMentions: IMentions = {};
|
||||
if (userIds.length > 0) {
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
collapseEqualLineRuns,
|
||||
diffLinesRaw,
|
||||
diffWords,
|
||||
type MessageDiffDisplay,
|
||||
} from './textDiff';
|
||||
|
||||
const partValues = (parts: ReturnType<typeof diffWords>) =>
|
||||
@@ -89,10 +90,10 @@ describe('collapseEqualLineRuns', () => {
|
||||
describe('buildMessageDiffDisplay', () => {
|
||||
it('uses inline word diff for single-line edits', () => {
|
||||
const display = buildMessageDiffDisplay('hello', 'hello world');
|
||||
expect(display.mode).toBe('inline');
|
||||
if (display.mode === 'inline') {
|
||||
expect(partValues(display.parts)).toEqual(['equal:"hello"', 'insert:" world"']);
|
||||
}
|
||||
expect(display).toEqual({
|
||||
mode: 'inline',
|
||||
parts: diffWords('hello', 'hello world'),
|
||||
});
|
||||
});
|
||||
|
||||
it('uses line diff with collapse for multiline edits', () => {
|
||||
@@ -101,10 +102,16 @@ describe('buildMessageDiffDisplay', () => {
|
||||
|
||||
const display = buildMessageDiffDisplay(oldText, newText);
|
||||
expect(display.mode).toBe('lines');
|
||||
if (display.mode === 'lines') {
|
||||
expect(display.rows.at(-2)).toEqual({ type: 'delete', text: 'old' });
|
||||
expect(display.rows.at(-1)).toEqual({ type: 'insert', text: 'new' });
|
||||
}
|
||||
const linesDisplay = display as Extract<MessageDiffDisplay, { mode: 'lines' }>;
|
||||
expect(linesDisplay).toMatchObject({
|
||||
mode: 'lines',
|
||||
rows: expect.arrayContaining([
|
||||
{ type: 'delete', text: 'old' },
|
||||
{ type: 'insert', text: 'new' },
|
||||
]),
|
||||
});
|
||||
expect(linesDisplay.rows.at(-2)).toEqual({ type: 'delete', text: 'old' });
|
||||
expect(linesDisplay.rows.at(-1)).toEqual({ type: 'insert', text: 'new' });
|
||||
});
|
||||
|
||||
it('collapses unchanged lines in multiline diffs', () => {
|
||||
@@ -114,9 +121,8 @@ describe('buildMessageDiffDisplay', () => {
|
||||
|
||||
const display = buildMessageDiffDisplay(oldText, newText);
|
||||
expect(display.mode).toBe('lines');
|
||||
if (display.mode === 'lines') {
|
||||
expect(display.rows.some((row) => row.type === 'skip')).toBe(true);
|
||||
}
|
||||
const linesDisplay = display as Extract<MessageDiffDisplay, { mode: 'lines' }>;
|
||||
expect(linesDisplay.rows.some((row) => row.type === 'skip')).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -101,25 +101,25 @@ describe('SlidingSyncManager.dispose()', () => {
|
||||
|
||||
// ── onMembershipLeave: auto-unsubscribe on leave/ban ─────────────────────────
|
||||
|
||||
describe('SlidingSyncManager — membership leave auto-unsubscribe', () => {
|
||||
/** Fire the RoomMemberEvent.Membership listener registered on mx.on */
|
||||
function fireMembershipEvent(
|
||||
mx: ReturnType<typeof makeMockMx>,
|
||||
membership: string,
|
||||
roomId = '!room:example.com',
|
||||
userId = '@user:example.com'
|
||||
) {
|
||||
const onCall = (mx.on as ReturnType<typeof vi.fn>).mock.calls.find(
|
||||
(args: unknown[]) => args[0] === 'RoomMember.membership'
|
||||
);
|
||||
if (!onCall) throw new Error('onMembershipLeave listener not registered');
|
||||
const [, handler] = onCall as [
|
||||
string,
|
||||
(e: unknown, m: { userId: string; roomId: string; membership: string }) => void,
|
||||
];
|
||||
handler(undefined, { userId, roomId, membership });
|
||||
}
|
||||
/** Fire the RoomMemberEvent.Membership listener registered on mx.on */
|
||||
function fireMembershipEvent(
|
||||
mx: ReturnType<typeof makeMockMx>,
|
||||
membership: string,
|
||||
roomId = '!room:example.com',
|
||||
userId = '@user:example.com'
|
||||
) {
|
||||
const onCall = (mx.on as ReturnType<typeof vi.fn>).mock.calls.find(
|
||||
(args: unknown[]) => args[0] === 'RoomMember.membership'
|
||||
);
|
||||
if (!onCall) throw new Error('onMembershipLeave listener not registered');
|
||||
const [, handler] = onCall as [
|
||||
string,
|
||||
(e: unknown, m: { userId: string; roomId: string; membership: string }) => void,
|
||||
];
|
||||
handler(undefined, { userId, roomId, membership });
|
||||
}
|
||||
|
||||
describe('SlidingSyncManager — membership leave auto-unsubscribe', () => {
|
||||
it('unsubscribes when the local user leaves an active room', () => {
|
||||
const mx = makeMockMx();
|
||||
const manager = makeManager(mx);
|
||||
|
||||
+1
-7
@@ -1,10 +1,4 @@
|
||||
@font-face {
|
||||
font-family: Twemoji;
|
||||
src:
|
||||
url('../public/font/Twemoji.Mozilla.v15.1.0.woff2'),
|
||||
url('../public/font/Twemoji.Mozilla.v15.1.0.ttf');
|
||||
font-display: swap;
|
||||
}
|
||||
@import '@sableclient/twemoji-font';
|
||||
|
||||
:root {
|
||||
--tc-link: hsl(213deg 100% 45%);
|
||||
|
||||
+8
-9
@@ -49,6 +49,14 @@ const showUpdateAvailablePrompt = (registration: ServiceWorkerRegistration) => {
|
||||
}
|
||||
};
|
||||
|
||||
const sendSessionToSW = () => {
|
||||
// Use the active session from the new multi-session store, fall back to legacy
|
||||
const sessions = getLocalStorageItem<Sessions>(MATRIX_SESSIONS_KEY, []);
|
||||
const activeId = getLocalStorageItem<string | undefined>(ACTIVE_SESSION_KEY, undefined);
|
||||
const active = sessions.find((s) => s.userId === activeId) ?? sessions[0] ?? getFallbackSession();
|
||||
pushSessionToSW(active?.baseUrl, active?.accessToken, active?.userId);
|
||||
};
|
||||
|
||||
if ('serviceWorker' in navigator) {
|
||||
const isProduction = import.meta.env.MODE === 'production';
|
||||
const swUrl = isProduction
|
||||
@@ -75,15 +83,6 @@ if ('serviceWorker' in navigator) {
|
||||
});
|
||||
});
|
||||
|
||||
const sendSessionToSW = () => {
|
||||
// Use the active session from the new multi-session store, fall back to legacy
|
||||
const sessions = getLocalStorageItem<Sessions>(MATRIX_SESSIONS_KEY, []);
|
||||
const activeId = getLocalStorageItem<string | undefined>(ACTIVE_SESSION_KEY, undefined);
|
||||
const active =
|
||||
sessions.find((s) => s.userId === activeId) ?? sessions[0] ?? getFallbackSession();
|
||||
pushSessionToSW(active?.baseUrl, active?.accessToken, active?.userId);
|
||||
};
|
||||
|
||||
navigator.serviceWorker
|
||||
.register(swUrl)
|
||||
.then(sendSessionToSW)
|
||||
|
||||
Vendored
+2
@@ -1,3 +1,4 @@
|
||||
import type { AddedServersContent } from '$types/matrix/accountData';
|
||||
import type { PackContent, EmoteRoomsContent } from '$plugins/custom-emoji/types';
|
||||
import type { IRecentEmojiContent } from '$plugins/recent-emoji';
|
||||
import type { InCinnySpacesContent } from '$hooks/useSidebarItems';
|
||||
@@ -55,5 +56,6 @@ declare module 'matrix-js-sdk/lib/@types/event' {
|
||||
[prefix.MATRIX_SABLE_UNSTABLE_ACCOUNT_NICKNAMES_PROPERTY_NAME]: Record<string, string>;
|
||||
[prefix.MATRIX_SABLE_UNSTABLE_ACCOUNT_SETTINGS_PROPERTY_NAME]: Record<string, unknown>;
|
||||
[prefix.MATRIX_SABLE_UNSTABLE_DISMISSED_INVITES]: { roomIds: string[] };
|
||||
[prefix.MATRIX_SABLE_UNSTABLE_ACCOUNT_ADDED_SERVERS_PROPERTY_NAME]: AddedServersContent;
|
||||
}
|
||||
}
|
||||
@@ -11,12 +11,17 @@ export const CustomAccountDataEvent = {
|
||||
prefix.MATRIX_SABLE_UNSTABLE_ACCOUNT_PER_MESSAGE_PROFILES_PROPERTY_NAME,
|
||||
SableSettings: prefix.MATRIX_SABLE_UNSTABLE_ACCOUNT_SETTINGS_PROPERTY_NAME,
|
||||
SableDismissedInvites: prefix.MATRIX_SABLE_UNSTABLE_DISMISSED_INVITES,
|
||||
SableAddedServers: prefix.MATRIX_SABLE_UNSTABLE_ACCOUNT_ADDED_SERVERS_PROPERTY_NAME,
|
||||
} as const;
|
||||
export type CustomAccountDataEvent =
|
||||
(typeof CustomAccountDataEvent)[keyof typeof CustomAccountDataEvent];
|
||||
|
||||
export type MDirectContent = Record<string, string[]>;
|
||||
|
||||
export type AddedServersContent = {
|
||||
servers: string[];
|
||||
};
|
||||
|
||||
export type SecretStorageDefaultKeyContent = {
|
||||
key: string;
|
||||
};
|
||||
|
||||
@@ -13,3 +13,4 @@ export const MATRIX_SABLE_UNSTABLE_ACCOUNT_PER_MESSAGE_PROFILES_PROPERTY_NAME =
|
||||
'fyi.cisnt.permessageprofile';
|
||||
|
||||
export const MATRIX_SABLE_UNSTABLE_DISMISSED_INVITES = 'moe.sable.dismissed_invites';
|
||||
export const MATRIX_SABLE_UNSTABLE_ACCOUNT_ADDED_SERVERS_PROPERTY_NAME = 'moe.sable.added_servers';
|
||||
@@ -255,6 +255,9 @@ export default defineConfig(({ command }) => ({
|
||||
outDir: 'dist',
|
||||
sourcemap: true,
|
||||
copyPublicDir: false,
|
||||
// es2022+ avoids esbuild 0.27.7 failing to downlevel destructuring when
|
||||
// vite-plugin-top-level-await re-transpiles chunks (see vitejs/vite#22225).
|
||||
target: 'es2022',
|
||||
rollupOptions: {
|
||||
plugins: [inject({ Buffer: ['buffer', 'Buffer'] }) as PluginOption],
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user