Compare commits
27 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
444b2feb9e | ||
|
|
f35aa384e5 | ||
|
|
b5fd41f862 | ||
|
|
3d4c91c969 | ||
|
|
38cc6e6f3a | ||
|
|
12bcbc2e78 | ||
|
|
e44ca92422 | ||
|
|
174b315278 | ||
|
|
d73428ee3d | ||
|
|
f2c5a595b9 | ||
|
|
f55a3764d5 | ||
|
|
3bdcf37bf0 | ||
|
|
9d7808ec46 | ||
|
|
20d30903fd | ||
|
|
a6a3ac3b24 | ||
|
|
67c6785bf3 | ||
|
|
b78f6f23b5 | ||
|
|
867a47218a | ||
|
|
d36938e1fd | ||
|
|
1914606895 | ||
|
|
19096c3543 | ||
|
|
afc251aa7c | ||
|
|
31efbf73b7 | ||
|
|
737cc09fea | ||
|
|
154f234d0c | ||
|
|
31c6d13fdf | ||
|
|
b3497d9ed6 |
4
.github/workflows/prod-deploy.yml
vendored
4
.github/workflows/prod-deploy.yml
vendored
@@ -52,7 +52,7 @@ jobs:
|
|||||||
gpg --export | xxd -p
|
gpg --export | xxd -p
|
||||||
echo '${{ secrets.GNUPG_PASSPHRASE }}' | gpg --batch --yes --pinentry-mode loopback --passphrase-fd 0 --armor --detach-sign cinny-${{ steps.vars.outputs.tag }}.tar.gz
|
echo '${{ secrets.GNUPG_PASSPHRASE }}' | gpg --batch --yes --pinentry-mode loopback --passphrase-fd 0 --armor --detach-sign cinny-${{ steps.vars.outputs.tag }}.tar.gz
|
||||||
- name: Upload tagged release
|
- name: Upload tagged release
|
||||||
uses: softprops/action-gh-release@72f2c25fcb47643c292f7107632f7a47c1df5cd8
|
uses: softprops/action-gh-release@6cbd405e2c4e67a21c47fa9e383d020e4e28b836
|
||||||
with:
|
with:
|
||||||
files: |
|
files: |
|
||||||
cinny-${{ steps.vars.outputs.tag }}.tar.gz
|
cinny-${{ steps.vars.outputs.tag }}.tar.gz
|
||||||
@@ -70,7 +70,7 @@ jobs:
|
|||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v3.6.0
|
uses: docker/setup-qemu-action@v3.6.0
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3.10.0
|
uses: docker/setup-buildx-action@v3.11.1
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
uses: docker/login-action@v3.5.0
|
uses: docker/login-action@v3.5.0
|
||||||
with:
|
with:
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ RUN npm run build
|
|||||||
|
|
||||||
|
|
||||||
## App
|
## App
|
||||||
FROM nginx:1.29.0-alpine
|
FROM nginx:1.29.1-alpine
|
||||||
|
|
||||||
COPY --from=builder /src/dist /app
|
COPY --from=builder /src/dist /app
|
||||||
COPY --from=builder /src/docker-nginx.conf /etc/nginx/conf.d/default.conf
|
COPY --from=builder /src/docker-nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
|
|||||||
@@ -90,6 +90,7 @@
|
|||||||
window.global ||= window;
|
window.global ||= window;
|
||||||
</script>
|
</script>
|
||||||
<div id="root"></div>
|
<div id="root"></div>
|
||||||
|
<div id="portalContainer"></div>
|
||||||
<script type="module" src="./src/index.tsx"></script>
|
<script type="module" src="./src/index.tsx"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
33
package-lock.json
generated
33
package-lock.json
generated
@@ -32,7 +32,7 @@
|
|||||||
"emojibase-data": "15.3.2",
|
"emojibase-data": "15.3.2",
|
||||||
"file-saver": "2.0.5",
|
"file-saver": "2.0.5",
|
||||||
"focus-trap-react": "10.0.2",
|
"focus-trap-react": "10.0.2",
|
||||||
"folds": "2.2.0",
|
"folds": "2.5.0",
|
||||||
"html-dom-parser": "4.0.0",
|
"html-dom-parser": "4.0.0",
|
||||||
"html-react-parser": "4.2.0",
|
"html-react-parser": "4.2.0",
|
||||||
"i18next": "23.12.2",
|
"i18next": "23.12.2",
|
||||||
@@ -43,7 +43,7 @@
|
|||||||
"jotai": "2.6.0",
|
"jotai": "2.6.0",
|
||||||
"linkify-react": "4.1.3",
|
"linkify-react": "4.1.3",
|
||||||
"linkifyjs": "4.1.3",
|
"linkifyjs": "4.1.3",
|
||||||
"matrix-js-sdk": "37.5.0",
|
"matrix-js-sdk": "38.2.0",
|
||||||
"millify": "6.1.0",
|
"millify": "6.1.0",
|
||||||
"pdfjs-dist": "4.2.67",
|
"pdfjs-dist": "4.2.67",
|
||||||
"prismjs": "1.30.0",
|
"prismjs": "1.30.0",
|
||||||
@@ -2256,20 +2256,14 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@matrix-org/matrix-sdk-crypto-wasm": {
|
"node_modules/@matrix-org/matrix-sdk-crypto-wasm": {
|
||||||
"version": "14.1.0",
|
"version": "15.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/@matrix-org/matrix-sdk-crypto-wasm/-/matrix-sdk-crypto-wasm-14.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@matrix-org/matrix-sdk-crypto-wasm/-/matrix-sdk-crypto-wasm-15.3.0.tgz",
|
||||||
"integrity": "sha512-vcSxHJIr6lP0Fgo8jl0sTHg+OZxZn+skGjiyB62erfgw/R2QqJl0ZVSY8SRcbk9LtHo/ZGld1tnaOyjL2e3cLQ==",
|
"integrity": "sha512-QyxHvncvkl7nf+tnn92PjQ54gMNV8hMSpiukiDgNrqF6IYwgySTlcSdkPYdw8QjZJ0NR6fnVrNzMec0OohM3wA==",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 18"
|
"node": ">= 18"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@matrix-org/olm": {
|
|
||||||
"version": "3.2.15",
|
|
||||||
"resolved": "https://registry.npmjs.org/@matrix-org/olm/-/olm-3.2.15.tgz",
|
|
||||||
"integrity": "sha512-S7lOrndAK9/8qOtaTq/WhttJC/o4GAzdfK0MUPpo8ApzsJEC0QjtwrkC3KBXdFP1cD1MXi/mlKR7aaoVMKgs6Q==",
|
|
||||||
"license": "Apache-2.0"
|
|
||||||
},
|
|
||||||
"node_modules/@nodelib/fs.scandir": {
|
"node_modules/@nodelib/fs.scandir": {
|
||||||
"version": "2.1.5",
|
"version": "2.1.5",
|
||||||
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
|
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
|
||||||
@@ -7163,9 +7157,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/folds": {
|
"node_modules/folds": {
|
||||||
"version": "2.2.0",
|
"version": "2.5.0",
|
||||||
"resolved": "https://registry.npmjs.org/folds/-/folds-2.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/folds/-/folds-2.5.0.tgz",
|
||||||
"integrity": "sha512-uOfck5eWEIK11rhOAEdSoPIvMXwv+D1Go03pxSAKezWVb+uRoBdmE6LEqiLOF+ac4DGmZRMPvpdDsXCg7EVNIg==",
|
"integrity": "sha512-UJhvXAQ1XnZ9w10KJwSW+frvzzWE/zcF0dH3fDVCD70RFHAxwEi0UkkVS8CaZGxZF2Wvt3qTJyTS5LW3LwwUAw==",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@vanilla-extract/css": "1.9.2",
|
"@vanilla-extract/css": "1.9.2",
|
||||||
@@ -8631,14 +8625,13 @@
|
|||||||
"license": "Apache-2.0"
|
"license": "Apache-2.0"
|
||||||
},
|
},
|
||||||
"node_modules/matrix-js-sdk": {
|
"node_modules/matrix-js-sdk": {
|
||||||
"version": "37.5.0",
|
"version": "38.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/matrix-js-sdk/-/matrix-js-sdk-37.5.0.tgz",
|
"resolved": "https://registry.npmjs.org/matrix-js-sdk/-/matrix-js-sdk-38.2.0.tgz",
|
||||||
"integrity": "sha512-5tyuAi5hnKud1UkVq8Z2/3c22hWGELBZzErJPZkE6Hju2uGUfGtrIx6uj6puv0ZjvsUU3X6Qgm8vdReKO1PGig==",
|
"integrity": "sha512-R3jzK8rDGi/3OXOax8jFFyxblCG9KTT5yuXAbvnZCGcpTm8lZ4mHQAn5UydVD8qiyUMNMpaaMd6/k7N+5I/yaQ==",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime": "^7.12.5",
|
"@babel/runtime": "^7.12.5",
|
||||||
"@matrix-org/matrix-sdk-crypto-wasm": "^14.0.1",
|
"@matrix-org/matrix-sdk-crypto-wasm": "^15.1.0",
|
||||||
"@matrix-org/olm": "3.2.15",
|
|
||||||
"another-json": "^0.2.0",
|
"another-json": "^0.2.0",
|
||||||
"bs58": "^6.0.0",
|
"bs58": "^6.0.0",
|
||||||
"content-type": "^1.0.4",
|
"content-type": "^1.0.4",
|
||||||
@@ -8653,7 +8646,7 @@
|
|||||||
"uuid": "11"
|
"uuid": "11"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=20.0.0"
|
"node": ">=22.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/matrix-js-sdk/node_modules/uuid": {
|
"node_modules/matrix-js-sdk/node_modules/uuid": {
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
"emojibase-data": "15.3.2",
|
"emojibase-data": "15.3.2",
|
||||||
"file-saver": "2.0.5",
|
"file-saver": "2.0.5",
|
||||||
"focus-trap-react": "10.0.2",
|
"focus-trap-react": "10.0.2",
|
||||||
"folds": "2.2.0",
|
"folds": "2.5.0",
|
||||||
"html-dom-parser": "4.0.0",
|
"html-dom-parser": "4.0.0",
|
||||||
"html-react-parser": "4.2.0",
|
"html-react-parser": "4.2.0",
|
||||||
"i18next": "23.12.2",
|
"i18next": "23.12.2",
|
||||||
@@ -54,7 +54,7 @@
|
|||||||
"jotai": "2.6.0",
|
"jotai": "2.6.0",
|
||||||
"linkify-react": "4.1.3",
|
"linkify-react": "4.1.3",
|
||||||
"linkifyjs": "4.1.3",
|
"linkifyjs": "4.1.3",
|
||||||
"matrix-js-sdk": "37.5.0",
|
"matrix-js-sdk": "38.2.0",
|
||||||
"millify": "6.1.0",
|
"millify": "6.1.0",
|
||||||
"pdfjs-dist": "4.2.67",
|
"pdfjs-dist": "4.2.67",
|
||||||
"prismjs": "1.30.0",
|
"prismjs": "1.30.0",
|
||||||
|
|||||||
@@ -209,13 +209,11 @@ export function RenderMessageContent({
|
|||||||
<MVideo
|
<MVideo
|
||||||
content={getContent()}
|
content={getContent()}
|
||||||
renderAsFile={renderFile}
|
renderAsFile={renderFile}
|
||||||
renderVideoContent={({ body, info, mimeType, url, encInfo }) => (
|
renderVideoContent={({ body, info, ...props }) => (
|
||||||
<VideoContent
|
<VideoContent
|
||||||
body={body}
|
body={body}
|
||||||
info={info}
|
info={info}
|
||||||
mimeType={mimeType}
|
{...props}
|
||||||
url={url}
|
|
||||||
encInfo={encInfo}
|
|
||||||
renderThumbnail={
|
renderThumbnail={
|
||||||
mediaAutoLoad
|
mediaAutoLoad
|
||||||
? () => (
|
? () => (
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
34
src/app/components/emoji-board/components/Group.tsx
Normal file
34
src/app/components/emoji-board/components/Group.tsx
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
import { as, Box, Text } from 'folds';
|
||||||
|
import React, { ReactNode } from 'react';
|
||||||
|
import classNames from 'classnames';
|
||||||
|
import * as css from './styles.css';
|
||||||
|
|
||||||
|
export const getDOMGroupId = (id: string): string => `EmojiBoardGroup-${id}`;
|
||||||
|
|
||||||
|
export const EmojiGroup = as<
|
||||||
|
'div',
|
||||||
|
{
|
||||||
|
id: string;
|
||||||
|
label: string;
|
||||||
|
children: ReactNode;
|
||||||
|
}
|
||||||
|
>(({ className, id, label, children, ...props }, ref) => (
|
||||||
|
<Box
|
||||||
|
id={getDOMGroupId(id)}
|
||||||
|
data-group-id={id}
|
||||||
|
className={classNames(css.EmojiGroup, className)}
|
||||||
|
direction="Column"
|
||||||
|
gap="200"
|
||||||
|
{...props}
|
||||||
|
ref={ref}
|
||||||
|
>
|
||||||
|
<Text id={`EmojiGroup-${id}-label`} as="label" className={css.EmojiGroupLabel} size="O400">
|
||||||
|
{label}
|
||||||
|
</Text>
|
||||||
|
<div aria-labelledby={`EmojiGroup-${id}-label`} className={css.EmojiGroupContent}>
|
||||||
|
<Box wrap="Wrap" justifyContent="Center">
|
||||||
|
{children}
|
||||||
|
</Box>
|
||||||
|
</div>
|
||||||
|
</Box>
|
||||||
|
));
|
||||||
105
src/app/components/emoji-board/components/Item.tsx
Normal file
105
src/app/components/emoji-board/components/Item.tsx
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { Box } from 'folds';
|
||||||
|
import { MatrixClient } from 'matrix-js-sdk';
|
||||||
|
import { EmojiItemInfo, EmojiType } from '../types';
|
||||||
|
import * as css from './styles.css';
|
||||||
|
import { PackImageReader } from '../../../plugins/custom-emoji';
|
||||||
|
import { IEmoji } from '../../../plugins/emoji';
|
||||||
|
import { mxcUrlToHttp } from '../../../utils/matrix';
|
||||||
|
|
||||||
|
export const getEmojiItemInfo = (element: Element): EmojiItemInfo | undefined => {
|
||||||
|
const label = element.getAttribute('title');
|
||||||
|
const type = element.getAttribute('data-emoji-type') as EmojiType | undefined;
|
||||||
|
const data = element.getAttribute('data-emoji-data');
|
||||||
|
const shortcode = element.getAttribute('data-emoji-shortcode');
|
||||||
|
|
||||||
|
if (type && data && shortcode && label)
|
||||||
|
return {
|
||||||
|
type,
|
||||||
|
data,
|
||||||
|
shortcode,
|
||||||
|
label,
|
||||||
|
};
|
||||||
|
return undefined;
|
||||||
|
};
|
||||||
|
|
||||||
|
type EmojiItemProps = {
|
||||||
|
emoji: IEmoji;
|
||||||
|
};
|
||||||
|
export function EmojiItem({ emoji }: EmojiItemProps) {
|
||||||
|
return (
|
||||||
|
<Box
|
||||||
|
as="button"
|
||||||
|
type="button"
|
||||||
|
alignItems="Center"
|
||||||
|
justifyContent="Center"
|
||||||
|
className={css.EmojiItem}
|
||||||
|
title={emoji.label}
|
||||||
|
aria-label={`${emoji.label} emoji`}
|
||||||
|
data-emoji-type={EmojiType.Emoji}
|
||||||
|
data-emoji-data={emoji.unicode}
|
||||||
|
data-emoji-shortcode={emoji.shortcode}
|
||||||
|
>
|
||||||
|
{emoji.unicode}
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
type CustomEmojiItemProps = {
|
||||||
|
mx: MatrixClient;
|
||||||
|
useAuthentication?: boolean;
|
||||||
|
image: PackImageReader;
|
||||||
|
};
|
||||||
|
export function CustomEmojiItem({ mx, useAuthentication, image }: CustomEmojiItemProps) {
|
||||||
|
return (
|
||||||
|
<Box
|
||||||
|
as="button"
|
||||||
|
type="button"
|
||||||
|
alignItems="Center"
|
||||||
|
justifyContent="Center"
|
||||||
|
className={css.EmojiItem}
|
||||||
|
title={image.body || image.shortcode}
|
||||||
|
aria-label={`${image.body || image.shortcode} emoji`}
|
||||||
|
data-emoji-type={EmojiType.CustomEmoji}
|
||||||
|
data-emoji-data={image.url}
|
||||||
|
data-emoji-shortcode={image.shortcode}
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
loading="lazy"
|
||||||
|
className={css.CustomEmojiImg}
|
||||||
|
alt={image.body || image.shortcode}
|
||||||
|
src={mxcUrlToHttp(mx, image.url, useAuthentication) ?? image.url}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
type StickerItemProps = {
|
||||||
|
mx: MatrixClient;
|
||||||
|
useAuthentication?: boolean;
|
||||||
|
image: PackImageReader;
|
||||||
|
};
|
||||||
|
|
||||||
|
export function StickerItem({ mx, useAuthentication, image }: StickerItemProps) {
|
||||||
|
return (
|
||||||
|
<Box
|
||||||
|
as="button"
|
||||||
|
type="button"
|
||||||
|
alignItems="Center"
|
||||||
|
justifyContent="Center"
|
||||||
|
className={css.StickerItem}
|
||||||
|
title={image.body || image.shortcode}
|
||||||
|
aria-label={`${image.body || image.shortcode} emoji`}
|
||||||
|
data-emoji-type={EmojiType.Sticker}
|
||||||
|
data-emoji-data={image.url}
|
||||||
|
data-emoji-shortcode={image.shortcode}
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
loading="lazy"
|
||||||
|
className={css.StickerImg}
|
||||||
|
alt={image.body || image.shortcode}
|
||||||
|
src={mxcUrlToHttp(mx, image.url, useAuthentication) ?? image.url}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
}
|
||||||
30
src/app/components/emoji-board/components/Layout.tsx
Normal file
30
src/app/components/emoji-board/components/Layout.tsx
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
import { as, Box, Line } from 'folds';
|
||||||
|
import React, { ReactNode } from 'react';
|
||||||
|
import classNames from 'classnames';
|
||||||
|
import * as css from './styles.css';
|
||||||
|
|
||||||
|
export const EmojiBoardLayout = as<
|
||||||
|
'div',
|
||||||
|
{
|
||||||
|
header: ReactNode;
|
||||||
|
sidebar?: ReactNode;
|
||||||
|
children: ReactNode;
|
||||||
|
}
|
||||||
|
>(({ className, header, sidebar, children, ...props }, ref) => (
|
||||||
|
<Box
|
||||||
|
display="InlineFlex"
|
||||||
|
className={classNames(css.Base, className)}
|
||||||
|
direction="Row"
|
||||||
|
{...props}
|
||||||
|
ref={ref}
|
||||||
|
>
|
||||||
|
<Box direction="Column" grow="Yes">
|
||||||
|
<Box className={css.Header} direction="Column" shrink="No">
|
||||||
|
{header}
|
||||||
|
</Box>
|
||||||
|
{children}
|
||||||
|
</Box>
|
||||||
|
<Line size="300" direction="Vertical" />
|
||||||
|
{sidebar}
|
||||||
|
</Box>
|
||||||
|
));
|
||||||
22
src/app/components/emoji-board/components/NoStickerPacks.tsx
Normal file
22
src/app/components/emoji-board/components/NoStickerPacks.tsx
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { Box, toRem, config, Icons, Icon, Text } from 'folds';
|
||||||
|
|
||||||
|
export function NoStickerPacks() {
|
||||||
|
return (
|
||||||
|
<Box
|
||||||
|
style={{ padding: `${toRem(60)} ${config.space.S500}` }}
|
||||||
|
alignItems="Center"
|
||||||
|
justifyContent="Center"
|
||||||
|
direction="Column"
|
||||||
|
gap="300"
|
||||||
|
>
|
||||||
|
<Icon size="600" src={Icons.Sticker} />
|
||||||
|
<Box direction="Inherit">
|
||||||
|
<Text align="Center">No Sticker Packs!</Text>
|
||||||
|
<Text priority="300" align="Center" size="T200">
|
||||||
|
Add stickers from user, room or space settings.
|
||||||
|
</Text>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
}
|
||||||
53
src/app/components/emoji-board/components/Preview.tsx
Normal file
53
src/app/components/emoji-board/components/Preview.tsx
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
import { Box, Text } from 'folds';
|
||||||
|
import React from 'react';
|
||||||
|
import { Atom, atom, useAtomValue } from 'jotai';
|
||||||
|
import * as css from './styles.css';
|
||||||
|
import { useMatrixClient } from '../../../hooks/useMatrixClient';
|
||||||
|
import { useMediaAuthentication } from '../../../hooks/useMediaAuthentication';
|
||||||
|
import { mxcUrlToHttp } from '../../../utils/matrix';
|
||||||
|
|
||||||
|
export type PreviewData = {
|
||||||
|
key: string;
|
||||||
|
shortcode: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const createPreviewDataAtom = (initial?: PreviewData) =>
|
||||||
|
atom<PreviewData | undefined>(initial);
|
||||||
|
|
||||||
|
type PreviewProps = {
|
||||||
|
previewAtom: Atom<PreviewData | undefined>;
|
||||||
|
};
|
||||||
|
export function Preview({ previewAtom }: PreviewProps) {
|
||||||
|
const mx = useMatrixClient();
|
||||||
|
const useAuthentication = useMediaAuthentication();
|
||||||
|
|
||||||
|
const { key, shortcode } = useAtomValue(previewAtom) ?? {};
|
||||||
|
|
||||||
|
if (!shortcode) return null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box shrink="No" className={css.Preview} gap="300" alignItems="Center">
|
||||||
|
{key && (
|
||||||
|
<Box
|
||||||
|
display="InlineFlex"
|
||||||
|
className={css.PreviewEmoji}
|
||||||
|
alignItems="Center"
|
||||||
|
justifyContent="Center"
|
||||||
|
>
|
||||||
|
{key.startsWith('mxc://') ? (
|
||||||
|
<img
|
||||||
|
className={css.PreviewImg}
|
||||||
|
src={mxcUrlToHttp(mx, key, useAuthentication) ?? key}
|
||||||
|
alt={shortcode}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
key
|
||||||
|
)}
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
|
<Text size="H5" truncate>
|
||||||
|
:{shortcode}:
|
||||||
|
</Text>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
}
|
||||||
51
src/app/components/emoji-board/components/SearchInput.tsx
Normal file
51
src/app/components/emoji-board/components/SearchInput.tsx
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
import React, { ChangeEventHandler, useRef } from 'react';
|
||||||
|
import { Input, Chip, Icon, Icons, Text } from 'folds';
|
||||||
|
import { mobileOrTablet } from '../../../utils/user-agent';
|
||||||
|
|
||||||
|
type SearchInputProps = {
|
||||||
|
query?: string;
|
||||||
|
onChange: ChangeEventHandler<HTMLInputElement>;
|
||||||
|
allowTextCustomEmoji?: boolean;
|
||||||
|
onTextCustomEmojiSelect?: (text: string) => void;
|
||||||
|
};
|
||||||
|
export function SearchInput({
|
||||||
|
query,
|
||||||
|
onChange,
|
||||||
|
allowTextCustomEmoji,
|
||||||
|
onTextCustomEmojiSelect,
|
||||||
|
}: SearchInputProps) {
|
||||||
|
const inputRef = useRef<HTMLInputElement>(null);
|
||||||
|
|
||||||
|
const handleReact = () => {
|
||||||
|
const textEmoji = inputRef.current?.value.trim();
|
||||||
|
if (!textEmoji) return;
|
||||||
|
onTextCustomEmojiSelect?.(textEmoji);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Input
|
||||||
|
ref={inputRef}
|
||||||
|
variant="SurfaceVariant"
|
||||||
|
size="400"
|
||||||
|
placeholder={allowTextCustomEmoji ? 'Search or Text Reaction ' : 'Search'}
|
||||||
|
maxLength={50}
|
||||||
|
after={
|
||||||
|
allowTextCustomEmoji && query ? (
|
||||||
|
<Chip
|
||||||
|
variant="Primary"
|
||||||
|
radii="Pill"
|
||||||
|
after={<Icon src={Icons.ArrowRight} size="50" />}
|
||||||
|
outlined
|
||||||
|
onClick={handleReact}
|
||||||
|
>
|
||||||
|
<Text size="L400">React</Text>
|
||||||
|
</Chip>
|
||||||
|
) : (
|
||||||
|
<Icon src={Icons.Search} size="50" />
|
||||||
|
)
|
||||||
|
}
|
||||||
|
onChange={onChange}
|
||||||
|
autoFocus={!mobileOrTablet()}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
130
src/app/components/emoji-board/components/Sidebar.tsx
Normal file
130
src/app/components/emoji-board/components/Sidebar.tsx
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
import React, { ReactNode } from 'react';
|
||||||
|
import {
|
||||||
|
Box,
|
||||||
|
Scroll,
|
||||||
|
Line,
|
||||||
|
as,
|
||||||
|
TooltipProvider,
|
||||||
|
Tooltip,
|
||||||
|
Text,
|
||||||
|
IconButton,
|
||||||
|
Icon,
|
||||||
|
IconSrc,
|
||||||
|
Icons,
|
||||||
|
} from 'folds';
|
||||||
|
import classNames from 'classnames';
|
||||||
|
import * as css from './styles.css';
|
||||||
|
|
||||||
|
export function Sidebar({ children }: { children: ReactNode }) {
|
||||||
|
return (
|
||||||
|
<Box className={css.Sidebar} shrink="No">
|
||||||
|
<Scroll size="0">
|
||||||
|
<Box className={css.SidebarContent} direction="Column" alignItems="Center" gap="100">
|
||||||
|
{children}
|
||||||
|
</Box>
|
||||||
|
</Scroll>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export const SidebarStack = as<'div'>(({ className, children, ...props }, ref) => (
|
||||||
|
<Box
|
||||||
|
className={classNames(css.SidebarStack, className)}
|
||||||
|
direction="Column"
|
||||||
|
alignItems="Center"
|
||||||
|
gap="100"
|
||||||
|
{...props}
|
||||||
|
ref={ref}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</Box>
|
||||||
|
));
|
||||||
|
export function SidebarDivider() {
|
||||||
|
return <Line className={css.SidebarDivider} size="300" variant="Surface" />;
|
||||||
|
}
|
||||||
|
|
||||||
|
function SidebarBtn<T extends string>({
|
||||||
|
active,
|
||||||
|
label,
|
||||||
|
id,
|
||||||
|
onClick,
|
||||||
|
children,
|
||||||
|
}: {
|
||||||
|
active?: boolean;
|
||||||
|
label: string;
|
||||||
|
id: T;
|
||||||
|
onClick: (id: T) => void;
|
||||||
|
children: ReactNode;
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<TooltipProvider
|
||||||
|
delay={500}
|
||||||
|
position="Left"
|
||||||
|
tooltip={
|
||||||
|
<Tooltip id={`SidebarStackItem-${id}-label`}>
|
||||||
|
<Text size="T300">{label}</Text>
|
||||||
|
</Tooltip>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{(ref) => (
|
||||||
|
<IconButton
|
||||||
|
aria-pressed={active}
|
||||||
|
aria-labelledby={`SidebarStackItem-${id}-label`}
|
||||||
|
ref={ref}
|
||||||
|
onClick={() => onClick(id)}
|
||||||
|
size="400"
|
||||||
|
radii="300"
|
||||||
|
variant="Surface"
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</IconButton>
|
||||||
|
)}
|
||||||
|
</TooltipProvider>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
type GroupIconProps<T extends string> = {
|
||||||
|
active: boolean;
|
||||||
|
id: T;
|
||||||
|
label: string;
|
||||||
|
icon: IconSrc;
|
||||||
|
onClick: (id: T) => void;
|
||||||
|
};
|
||||||
|
export function GroupIcon<T extends string>({
|
||||||
|
active,
|
||||||
|
id,
|
||||||
|
label,
|
||||||
|
icon,
|
||||||
|
onClick,
|
||||||
|
}: GroupIconProps<T>) {
|
||||||
|
return (
|
||||||
|
<SidebarBtn active={active} id={id} label={label} onClick={onClick}>
|
||||||
|
<Icon src={icon} filled={active} />
|
||||||
|
</SidebarBtn>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
type ImageGroupIconProps<T extends string> = {
|
||||||
|
active: boolean;
|
||||||
|
id: T;
|
||||||
|
label: string;
|
||||||
|
url?: string;
|
||||||
|
onClick: (id: T) => void;
|
||||||
|
};
|
||||||
|
export function ImageGroupIcon<T extends string>({
|
||||||
|
active,
|
||||||
|
id,
|
||||||
|
label,
|
||||||
|
url,
|
||||||
|
onClick,
|
||||||
|
}: ImageGroupIconProps<T>) {
|
||||||
|
return (
|
||||||
|
<SidebarBtn active={active} id={id} label={label} onClick={onClick}>
|
||||||
|
{url ? (
|
||||||
|
<img className={css.SidebarBtnImg} src={url} alt={label} />
|
||||||
|
) : (
|
||||||
|
<Icon src={Icons.Photo} filled={active} />
|
||||||
|
)}
|
||||||
|
</SidebarBtn>
|
||||||
|
);
|
||||||
|
}
|
||||||
44
src/app/components/emoji-board/components/Tabs.tsx
Normal file
44
src/app/components/emoji-board/components/Tabs.tsx
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
import React, { CSSProperties } from 'react';
|
||||||
|
import { Badge, Box, Text } from 'folds';
|
||||||
|
import { EmojiBoardTab } from '../types';
|
||||||
|
|
||||||
|
const styles: CSSProperties = {
|
||||||
|
cursor: 'pointer',
|
||||||
|
};
|
||||||
|
|
||||||
|
export function EmojiBoardTabs({
|
||||||
|
tab,
|
||||||
|
onTabChange,
|
||||||
|
}: {
|
||||||
|
tab: EmojiBoardTab;
|
||||||
|
onTabChange: (tab: EmojiBoardTab) => void;
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<Box gap="100">
|
||||||
|
<Badge
|
||||||
|
style={styles}
|
||||||
|
as="button"
|
||||||
|
variant="Secondary"
|
||||||
|
fill={tab === EmojiBoardTab.Sticker ? 'Solid' : 'None'}
|
||||||
|
size="500"
|
||||||
|
onClick={() => onTabChange(EmojiBoardTab.Sticker)}
|
||||||
|
>
|
||||||
|
<Text as="span" size="L400">
|
||||||
|
Sticker
|
||||||
|
</Text>
|
||||||
|
</Badge>
|
||||||
|
<Badge
|
||||||
|
style={styles}
|
||||||
|
as="button"
|
||||||
|
variant="Secondary"
|
||||||
|
fill={tab === EmojiBoardTab.Emoji ? 'Solid' : 'None'}
|
||||||
|
size="500"
|
||||||
|
onClick={() => onTabChange(EmojiBoardTab.Emoji)}
|
||||||
|
>
|
||||||
|
<Text as="span" size="L400">
|
||||||
|
Emoji
|
||||||
|
</Text>
|
||||||
|
</Badge>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
}
|
||||||
8
src/app/components/emoji-board/components/index.tsx
Normal file
8
src/app/components/emoji-board/components/index.tsx
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
export * from './SearchInput';
|
||||||
|
export * from './Tabs';
|
||||||
|
export * from './Sidebar';
|
||||||
|
export * from './NoStickerPacks';
|
||||||
|
export * from './Preview';
|
||||||
|
export * from './Item';
|
||||||
|
export * from './Group';
|
||||||
|
export * from './Layout';
|
||||||
@@ -1,5 +1,9 @@
|
|||||||
import { style } from '@vanilla-extract/css';
|
import { style } from '@vanilla-extract/css';
|
||||||
import { DefaultReset, FocusOutline, color, config, toRem } from 'folds';
|
import { toRem, color, config, DefaultReset, FocusOutline } from 'folds';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Layout
|
||||||
|
*/
|
||||||
|
|
||||||
export const Base = style({
|
export const Base = style({
|
||||||
maxWidth: toRem(432),
|
maxWidth: toRem(432),
|
||||||
@@ -13,6 +17,15 @@ export const Base = style({
|
|||||||
overflow: 'hidden',
|
overflow: 'hidden',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const Header = style({
|
||||||
|
padding: config.space.S300,
|
||||||
|
paddingBottom: 0,
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sidebar
|
||||||
|
*/
|
||||||
|
|
||||||
export const Sidebar = style({
|
export const Sidebar = style({
|
||||||
width: toRem(54),
|
width: toRem(54),
|
||||||
backgroundColor: color.Surface.Container,
|
backgroundColor: color.Surface.Container,
|
||||||
@@ -29,26 +42,21 @@ export const SidebarStack = style({
|
|||||||
backgroundColor: color.Surface.Container,
|
backgroundColor: color.Surface.Container,
|
||||||
});
|
});
|
||||||
|
|
||||||
export const NativeEmojiSidebarStack = style({
|
|
||||||
position: 'sticky',
|
|
||||||
bottom: '-67%',
|
|
||||||
zIndex: 1,
|
|
||||||
});
|
|
||||||
|
|
||||||
export const SidebarDivider = style({
|
export const SidebarDivider = style({
|
||||||
width: toRem(18),
|
width: toRem(18),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const Header = style({
|
export const SidebarBtnImg = style({
|
||||||
padding: config.space.S300,
|
width: toRem(24),
|
||||||
paddingBottom: 0,
|
height: toRem(24),
|
||||||
|
objectFit: 'contain',
|
||||||
});
|
});
|
||||||
|
|
||||||
export const EmojiBoardTab = style({
|
/**
|
||||||
cursor: 'pointer',
|
* Preview
|
||||||
});
|
*/
|
||||||
|
|
||||||
export const Footer = style({
|
export const Preview = style({
|
||||||
padding: config.space.S200,
|
padding: config.space.S200,
|
||||||
margin: config.space.S300,
|
margin: config.space.S300,
|
||||||
marginTop: 0,
|
marginTop: 0,
|
||||||
@@ -59,7 +67,30 @@ export const Footer = style({
|
|||||||
color: color.SurfaceVariant.OnContainer,
|
color: color.SurfaceVariant.OnContainer,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const PreviewEmoji = style([
|
||||||
|
DefaultReset,
|
||||||
|
{
|
||||||
|
width: toRem(32),
|
||||||
|
height: toRem(32),
|
||||||
|
fontSize: toRem(32),
|
||||||
|
lineHeight: toRem(32),
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
export const PreviewImg = style([
|
||||||
|
DefaultReset,
|
||||||
|
{
|
||||||
|
width: toRem(32),
|
||||||
|
height: toRem(32),
|
||||||
|
objectFit: 'contain',
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Group
|
||||||
|
*/
|
||||||
|
|
||||||
export const EmojiGroup = style({
|
export const EmojiGroup = style({
|
||||||
|
position: 'relative',
|
||||||
padding: `${config.space.S300} 0`,
|
padding: `${config.space.S300} 0`,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -82,15 +113,9 @@ export const EmojiGroupContent = style([
|
|||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
export const EmojiPreview = style([
|
/**
|
||||||
DefaultReset,
|
* Item
|
||||||
{
|
*/
|
||||||
width: toRem(32),
|
|
||||||
height: toRem(32),
|
|
||||||
fontSize: toRem(32),
|
|
||||||
lineHeight: toRem(32),
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
|
|
||||||
export const EmojiItem = style([
|
export const EmojiItem = style([
|
||||||
DefaultReset,
|
DefaultReset,
|
||||||
@@ -1 +1,2 @@
|
|||||||
export * from './EmojiBoard';
|
export * from './EmojiBoard';
|
||||||
|
export * from './types';
|
||||||
|
|||||||
17
src/app/components/emoji-board/types.ts
Normal file
17
src/app/components/emoji-board/types.ts
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
export enum EmojiBoardTab {
|
||||||
|
Emoji = 'Emoji',
|
||||||
|
Sticker = 'Sticker',
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum EmojiType {
|
||||||
|
Emoji = 'emoji',
|
||||||
|
CustomEmoji = 'customEmoji',
|
||||||
|
Sticker = 'sticker',
|
||||||
|
}
|
||||||
|
|
||||||
|
export type EmojiItemInfo = {
|
||||||
|
type: EmojiType;
|
||||||
|
data: string;
|
||||||
|
shortcode: string;
|
||||||
|
label: string;
|
||||||
|
};
|
||||||
@@ -224,6 +224,8 @@ type RenderVideoContentProps = {
|
|||||||
mimeType: string;
|
mimeType: string;
|
||||||
url: string;
|
url: string;
|
||||||
encInfo?: IEncryptedFile;
|
encInfo?: IEncryptedFile;
|
||||||
|
markedAsSpoiler?: boolean;
|
||||||
|
spoilerReason?: string;
|
||||||
};
|
};
|
||||||
type MVideoProps = {
|
type MVideoProps = {
|
||||||
content: IVideoContent;
|
content: IVideoContent;
|
||||||
@@ -274,6 +276,8 @@ export function MVideo({ content, renderAsFile, renderVideoContent, outlined }:
|
|||||||
mimeType: safeMimeType,
|
mimeType: safeMimeType,
|
||||||
url: mxcUrl,
|
url: mxcUrl,
|
||||||
encInfo: content.file,
|
encInfo: content.file,
|
||||||
|
markedAsSpoiler: content[MATRIX_SPOILER_PROPERTY_NAME],
|
||||||
|
spoilerReason: content[MATRIX_SPOILER_REASON_PROPERTY_NAME],
|
||||||
})}
|
})}
|
||||||
</AttachmentBox>
|
</AttachmentBox>
|
||||||
</Attachment>
|
</Attachment>
|
||||||
|
|||||||
6
src/app/components/message/Time.css.ts
Normal file
6
src/app/components/message/Time.css.ts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import { style } from '@vanilla-extract/css';
|
||||||
|
|
||||||
|
export const Time = style({
|
||||||
|
fontWeight: 'inherit',
|
||||||
|
flexShrink: 0,
|
||||||
|
});
|
||||||
@@ -1,12 +1,15 @@
|
|||||||
import React, { ComponentProps } from 'react';
|
import React, { ComponentProps } from 'react';
|
||||||
import { Text, as } from 'folds';
|
import { Text, as } from 'folds';
|
||||||
|
import classNames from 'classnames';
|
||||||
import { timeDayMonYear, timeHourMinute, today, yesterday } from '../../utils/time';
|
import { timeDayMonYear, timeHourMinute, today, yesterday } from '../../utils/time';
|
||||||
|
import * as css from './Time.css';
|
||||||
|
|
||||||
export type TimeProps = {
|
export type TimeProps = {
|
||||||
compact?: boolean;
|
compact?: boolean;
|
||||||
ts: number;
|
ts: number;
|
||||||
hour24Clock: boolean;
|
hour24Clock: boolean;
|
||||||
dateFormatString: string;
|
dateFormatString: string;
|
||||||
|
inheritPriority?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -22,7 +25,7 @@ export type TimeProps = {
|
|||||||
* @returns {React.ReactElement} A <Text as="time"> element with the formatted date/time.
|
* @returns {React.ReactElement} A <Text as="time"> element with the formatted date/time.
|
||||||
*/
|
*/
|
||||||
export const Time = as<'span', TimeProps & ComponentProps<typeof Text>>(
|
export const Time = as<'span', TimeProps & ComponentProps<typeof Text>>(
|
||||||
({ compact, hour24Clock, dateFormatString, ts, ...props }, ref) => {
|
({ compact, hour24Clock, dateFormatString, ts, inheritPriority, className, ...props }, ref) => {
|
||||||
const formattedTime = timeHourMinute(ts, hour24Clock);
|
const formattedTime = timeHourMinute(ts, hour24Clock);
|
||||||
|
|
||||||
let time = '';
|
let time = '';
|
||||||
@@ -33,11 +36,18 @@ export const Time = as<'span', TimeProps & ComponentProps<typeof Text>>(
|
|||||||
} else if (yesterday(ts)) {
|
} else if (yesterday(ts)) {
|
||||||
time = `Yesterday ${formattedTime}`;
|
time = `Yesterday ${formattedTime}`;
|
||||||
} else {
|
} else {
|
||||||
time = `${timeDayMonYear(ts, dateFormatString)} ${formattedTime}`;
|
time = `${timeDayMonYear(ts, dateFormatString)}, ${formattedTime}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Text as="time" style={{ flexShrink: 0 }} size="T200" priority="300" {...props} ref={ref}>
|
<Text
|
||||||
|
as="time"
|
||||||
|
className={classNames(css.Time, className)}
|
||||||
|
size="T200"
|
||||||
|
priority={inheritPriority ? undefined : '300'}
|
||||||
|
{...props}
|
||||||
|
ref={ref}
|
||||||
|
>
|
||||||
{time}
|
{time}
|
||||||
</Text>
|
</Text>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Box, Icon, IconSrc } from 'folds';
|
import { Box, Icon, IconSrc } from 'folds';
|
||||||
import React, { ReactNode } from 'react';
|
import React, { ReactNode } from 'react';
|
||||||
import { CompactLayout, ModernLayout } from '..';
|
import { BubbleLayout, CompactLayout, ModernLayout } from '..';
|
||||||
import { MessageLayout } from '../../../state/settings';
|
import { MessageLayout } from '../../../state/settings';
|
||||||
|
|
||||||
export type EventContentProps = {
|
export type EventContentProps = {
|
||||||
@@ -30,9 +30,15 @@ export function EventContent({ messageLayout, time, iconSrc, content }: EventCon
|
|||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
|
|
||||||
return messageLayout === MessageLayout.Compact ? (
|
if (messageLayout === MessageLayout.Compact) {
|
||||||
<CompactLayout before={beforeJSX}>{msgContentJSX}</CompactLayout>
|
return <CompactLayout before={beforeJSX}>{msgContentJSX}</CompactLayout>;
|
||||||
) : (
|
}
|
||||||
<ModernLayout before={beforeJSX}>{msgContentJSX}</ModernLayout>
|
if (messageLayout === MessageLayout.Bubble) {
|
||||||
);
|
return (
|
||||||
|
<BubbleLayout hideBubble before={beforeJSX}>
|
||||||
|
{msgContentJSX}
|
||||||
|
</BubbleLayout>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return <ModernLayout before={beforeJSX}>{msgContentJSX}</ModernLayout>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -214,7 +214,7 @@ export const ImageContent = as<'div', ImageContentProps>(
|
|||||||
)}
|
)}
|
||||||
{(srcState.status === AsyncStatus.Loading || srcState.status === AsyncStatus.Success) &&
|
{(srcState.status === AsyncStatus.Loading || srcState.status === AsyncStatus.Success) &&
|
||||||
!load &&
|
!load &&
|
||||||
!markedAsSpoiler && (
|
!blurred && (
|
||||||
<Box className={css.AbsoluteContainer} alignItems="Center" justifyContent="Center">
|
<Box className={css.AbsoluteContainer} alignItems="Center" justifyContent="Center">
|
||||||
<Spinner variant="Secondary" />
|
<Spinner variant="Secondary" />
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import {
|
|||||||
Badge,
|
Badge,
|
||||||
Box,
|
Box,
|
||||||
Button,
|
Button,
|
||||||
|
Chip,
|
||||||
Icon,
|
Icon,
|
||||||
Icons,
|
Icons,
|
||||||
Spinner,
|
Spinner,
|
||||||
@@ -47,6 +48,8 @@ type VideoContentProps = {
|
|||||||
info: IVideoInfo & IThumbnailContent;
|
info: IVideoInfo & IThumbnailContent;
|
||||||
encInfo?: EncryptedAttachmentInfo;
|
encInfo?: EncryptedAttachmentInfo;
|
||||||
autoPlay?: boolean;
|
autoPlay?: boolean;
|
||||||
|
markedAsSpoiler?: boolean;
|
||||||
|
spoilerReason?: string;
|
||||||
renderThumbnail?: () => ReactNode;
|
renderThumbnail?: () => ReactNode;
|
||||||
renderVideo: (props: RenderVideoProps) => ReactNode;
|
renderVideo: (props: RenderVideoProps) => ReactNode;
|
||||||
};
|
};
|
||||||
@@ -60,6 +63,8 @@ export const VideoContent = as<'div', VideoContentProps>(
|
|||||||
info,
|
info,
|
||||||
encInfo,
|
encInfo,
|
||||||
autoPlay,
|
autoPlay,
|
||||||
|
markedAsSpoiler,
|
||||||
|
spoilerReason,
|
||||||
renderThumbnail,
|
renderThumbnail,
|
||||||
renderVideo,
|
renderVideo,
|
||||||
...props
|
...props
|
||||||
@@ -72,6 +77,7 @@ export const VideoContent = as<'div', VideoContentProps>(
|
|||||||
|
|
||||||
const [load, setLoad] = useState(false);
|
const [load, setLoad] = useState(false);
|
||||||
const [error, setError] = useState(false);
|
const [error, setError] = useState(false);
|
||||||
|
const [blurred, setBlurred] = useState(markedAsSpoiler ?? false);
|
||||||
|
|
||||||
const [srcState, loadSrc] = useAsyncCallback(
|
const [srcState, loadSrc] = useAsyncCallback(
|
||||||
useCallback(async () => {
|
useCallback(async () => {
|
||||||
@@ -114,11 +120,15 @@ export const VideoContent = as<'div', VideoContentProps>(
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{renderThumbnail && !load && (
|
{renderThumbnail && !load && (
|
||||||
<Box className={css.AbsoluteContainer} alignItems="Center" justifyContent="Center">
|
<Box
|
||||||
|
className={classNames(css.AbsoluteContainer, blurred && css.Blur)}
|
||||||
|
alignItems="Center"
|
||||||
|
justifyContent="Center"
|
||||||
|
>
|
||||||
{renderThumbnail()}
|
{renderThumbnail()}
|
||||||
</Box>
|
</Box>
|
||||||
)}
|
)}
|
||||||
{!autoPlay && srcState.status === AsyncStatus.Idle && (
|
{!autoPlay && !blurred && srcState.status === AsyncStatus.Idle && (
|
||||||
<Box className={css.AbsoluteContainer} alignItems="Center" justifyContent="Center">
|
<Box className={css.AbsoluteContainer} alignItems="Center" justifyContent="Center">
|
||||||
<Button
|
<Button
|
||||||
variant="Secondary"
|
variant="Secondary"
|
||||||
@@ -133,7 +143,7 @@ export const VideoContent = as<'div', VideoContentProps>(
|
|||||||
</Box>
|
</Box>
|
||||||
)}
|
)}
|
||||||
{srcState.status === AsyncStatus.Success && (
|
{srcState.status === AsyncStatus.Success && (
|
||||||
<Box className={css.AbsoluteContainer}>
|
<Box className={classNames(css.AbsoluteContainer, blurred && css.Blur)}>
|
||||||
{renderVideo({
|
{renderVideo({
|
||||||
title: body,
|
title: body,
|
||||||
src: srcState.data,
|
src: srcState.data,
|
||||||
@@ -144,8 +154,39 @@ export const VideoContent = as<'div', VideoContentProps>(
|
|||||||
})}
|
})}
|
||||||
</Box>
|
</Box>
|
||||||
)}
|
)}
|
||||||
|
{blurred && !error && srcState.status !== AsyncStatus.Error && (
|
||||||
|
<Box className={css.AbsoluteContainer} alignItems="Center" justifyContent="Center">
|
||||||
|
<TooltipProvider
|
||||||
|
tooltip={
|
||||||
|
typeof spoilerReason === 'string' && (
|
||||||
|
<Tooltip variant="Secondary">
|
||||||
|
<Text>{spoilerReason}</Text>
|
||||||
|
</Tooltip>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
position="Top"
|
||||||
|
align="Center"
|
||||||
|
>
|
||||||
|
{(triggerRef) => (
|
||||||
|
<Chip
|
||||||
|
ref={triggerRef}
|
||||||
|
variant="Secondary"
|
||||||
|
radii="Pill"
|
||||||
|
size="500"
|
||||||
|
outlined
|
||||||
|
onClick={() => {
|
||||||
|
setBlurred(false);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Text size="B300">Spoiler</Text>
|
||||||
|
</Chip>
|
||||||
|
)}
|
||||||
|
</TooltipProvider>
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
{(srcState.status === AsyncStatus.Loading || srcState.status === AsyncStatus.Success) &&
|
{(srcState.status === AsyncStatus.Loading || srcState.status === AsyncStatus.Success) &&
|
||||||
!load && (
|
!load &&
|
||||||
|
!blurred && (
|
||||||
<Box className={css.AbsoluteContainer} alignItems="Center" justifyContent="Center">
|
<Box className={css.AbsoluteContainer} alignItems="Center" justifyContent="Center">
|
||||||
<Spinner variant="Secondary" />
|
<Spinner variant="Secondary" />
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -1,18 +1,63 @@
|
|||||||
import React, { ReactNode } from 'react';
|
import React, { ReactNode } from 'react';
|
||||||
import { Box, as } from 'folds';
|
import classNames from 'classnames';
|
||||||
|
import { Box, ContainerColor, as, color } from 'folds';
|
||||||
import * as css from './layout.css';
|
import * as css from './layout.css';
|
||||||
|
|
||||||
|
type BubbleArrowProps = {
|
||||||
|
variant: ContainerColor;
|
||||||
|
};
|
||||||
|
function BubbleLeftArrow({ variant }: BubbleArrowProps) {
|
||||||
|
return (
|
||||||
|
<svg
|
||||||
|
className={css.BubbleLeftArrow}
|
||||||
|
width="9"
|
||||||
|
height="8"
|
||||||
|
viewBox="0 0 9 8"
|
||||||
|
fill="none"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
fillRule="evenodd"
|
||||||
|
clipRule="evenodd"
|
||||||
|
d="M9.00004 8V0H4.82847C3.04666 0 2.15433 2.15428 3.41426 3.41421L8.00004 8H9.00004Z"
|
||||||
|
fill={color[variant].Container}
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
type BubbleLayoutProps = {
|
type BubbleLayoutProps = {
|
||||||
|
hideBubble?: boolean;
|
||||||
before?: ReactNode;
|
before?: ReactNode;
|
||||||
|
header?: ReactNode;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const BubbleLayout = as<'div', BubbleLayoutProps>(({ before, children, ...props }, ref) => (
|
export const BubbleLayout = as<'div', BubbleLayoutProps>(
|
||||||
<Box gap="300" {...props} ref={ref}>
|
({ hideBubble, before, header, children, ...props }, ref) => (
|
||||||
<Box className={css.BubbleBefore} shrink="No">
|
<Box gap="300" {...props} ref={ref}>
|
||||||
{before}
|
<Box className={css.BubbleBefore} shrink="No">
|
||||||
|
{before}
|
||||||
|
</Box>
|
||||||
|
<Box grow="Yes" direction="Column">
|
||||||
|
{header}
|
||||||
|
{hideBubble ? (
|
||||||
|
children
|
||||||
|
) : (
|
||||||
|
<Box>
|
||||||
|
<Box
|
||||||
|
className={
|
||||||
|
hideBubble
|
||||||
|
? undefined
|
||||||
|
: classNames(css.BubbleContent, before ? css.BubbleContentArrowLeft : undefined)
|
||||||
|
}
|
||||||
|
direction="Column"
|
||||||
|
>
|
||||||
|
{before ? <BubbleLeftArrow variant="SurfaceVariant" /> : null}
|
||||||
|
{children}
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
<Box className={css.BubbleContent} direction="Column">
|
)
|
||||||
{children}
|
);
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
));
|
|
||||||
|
|||||||
@@ -120,6 +120,7 @@ export const CompactHeader = style([
|
|||||||
export const AvatarBase = style({
|
export const AvatarBase = style({
|
||||||
paddingTop: toRem(4),
|
paddingTop: toRem(4),
|
||||||
transition: 'transform 200ms cubic-bezier(0, 0.8, 0.67, 0.97)',
|
transition: 'transform 200ms cubic-bezier(0, 0.8, 0.67, 0.97)',
|
||||||
|
display: 'flex',
|
||||||
alignSelf: 'start',
|
alignSelf: 'start',
|
||||||
|
|
||||||
selectors: {
|
selectors: {
|
||||||
@@ -133,14 +134,31 @@ export const ModernBefore = style({
|
|||||||
minWidth: toRem(36),
|
minWidth: toRem(36),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const BubbleBefore = style([ModernBefore]);
|
export const BubbleBefore = style({
|
||||||
|
minWidth: toRem(36),
|
||||||
|
});
|
||||||
|
|
||||||
export const BubbleContent = style({
|
export const BubbleContent = style({
|
||||||
maxWidth: toRem(800),
|
maxWidth: toRem(800),
|
||||||
padding: config.space.S200,
|
padding: config.space.S200,
|
||||||
backgroundColor: color.SurfaceVariant.Container,
|
backgroundColor: color.SurfaceVariant.Container,
|
||||||
color: color.SurfaceVariant.OnContainer,
|
color: color.SurfaceVariant.OnContainer,
|
||||||
borderRadius: config.radii.R400,
|
borderRadius: config.radii.R500,
|
||||||
|
position: 'relative',
|
||||||
|
});
|
||||||
|
|
||||||
|
export const BubbleContentArrowLeft = style({
|
||||||
|
borderTopLeftRadius: 0,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const BubbleLeftArrow = style({
|
||||||
|
width: toRem(9),
|
||||||
|
height: toRem(8),
|
||||||
|
|
||||||
|
position: 'absolute',
|
||||||
|
top: 0,
|
||||||
|
left: toRem(-8),
|
||||||
|
zIndex: 1,
|
||||||
});
|
});
|
||||||
|
|
||||||
export const Username = style({
|
export const Username = style({
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React, { useEffect } from 'react';
|
import React, { ReactNode, useEffect } from 'react';
|
||||||
import { Box, Chip, Icon, IconButton, Icons, Text, color, config, toRem } from 'folds';
|
import { Box, Chip, Icon, IconButton, Icons, Text, color, config, toRem } from 'folds';
|
||||||
import { UploadCard, UploadCardError, UploadCardProgress } from './UploadCard';
|
import { UploadCard, UploadCardError, UploadCardProgress } from './UploadCard';
|
||||||
import { UploadStatus, UploadSuccess, useBindUploadAtom } from '../../state/upload';
|
import { UploadStatus, UploadSuccess, useBindUploadAtom } from '../../state/upload';
|
||||||
@@ -13,8 +13,54 @@ import {
|
|||||||
import { useObjectURL } from '../../hooks/useObjectURL';
|
import { useObjectURL } from '../../hooks/useObjectURL';
|
||||||
import { useMediaConfig } from '../../hooks/useMediaConfig';
|
import { useMediaConfig } from '../../hooks/useMediaConfig';
|
||||||
|
|
||||||
type ImagePreviewProps = { fileItem: TUploadItem; onSpoiler: (marked: boolean) => void };
|
type PreviewImageProps = {
|
||||||
function ImagePreview({ fileItem, onSpoiler }: ImagePreviewProps) {
|
fileItem: TUploadItem;
|
||||||
|
};
|
||||||
|
function PreviewImage({ fileItem }: PreviewImageProps) {
|
||||||
|
const { originalFile, metadata } = fileItem;
|
||||||
|
const fileUrl = useObjectURL(originalFile);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<img
|
||||||
|
style={{
|
||||||
|
objectFit: 'contain',
|
||||||
|
width: '100%',
|
||||||
|
height: toRem(152),
|
||||||
|
filter: metadata.markedAsSpoiler ? 'blur(44px)' : undefined,
|
||||||
|
}}
|
||||||
|
alt={originalFile.name}
|
||||||
|
src={fileUrl}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
type PreviewVideoProps = {
|
||||||
|
fileItem: TUploadItem;
|
||||||
|
};
|
||||||
|
function PreviewVideo({ fileItem }: PreviewVideoProps) {
|
||||||
|
const { originalFile, metadata } = fileItem;
|
||||||
|
const fileUrl = useObjectURL(originalFile);
|
||||||
|
|
||||||
|
return (
|
||||||
|
// eslint-disable-next-line jsx-a11y/media-has-caption
|
||||||
|
<video
|
||||||
|
style={{
|
||||||
|
objectFit: 'contain',
|
||||||
|
width: '100%',
|
||||||
|
height: toRem(152),
|
||||||
|
filter: metadata.markedAsSpoiler ? 'blur(44px)' : undefined,
|
||||||
|
}}
|
||||||
|
src={fileUrl}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
type MediaPreviewProps = {
|
||||||
|
fileItem: TUploadItem;
|
||||||
|
onSpoiler: (marked: boolean) => void;
|
||||||
|
children: ReactNode;
|
||||||
|
};
|
||||||
|
function MediaPreview({ fileItem, onSpoiler, children }: MediaPreviewProps) {
|
||||||
const { originalFile, metadata } = fileItem;
|
const { originalFile, metadata } = fileItem;
|
||||||
const fileUrl = useObjectURL(originalFile);
|
const fileUrl = useObjectURL(originalFile);
|
||||||
|
|
||||||
@@ -27,16 +73,7 @@ function ImagePreview({ fileItem, onSpoiler }: ImagePreviewProps) {
|
|||||||
position: 'relative',
|
position: 'relative',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<img
|
{children}
|
||||||
style={{
|
|
||||||
objectFit: 'contain',
|
|
||||||
width: '100%',
|
|
||||||
height: toRem(152),
|
|
||||||
filter: fileItem.metadata.markedAsSpoiler ? 'blur(44px)' : undefined,
|
|
||||||
}}
|
|
||||||
src={fileUrl}
|
|
||||||
alt={originalFile.name}
|
|
||||||
/>
|
|
||||||
<Box
|
<Box
|
||||||
justifyContent="End"
|
justifyContent="End"
|
||||||
style={{
|
style={{
|
||||||
@@ -136,7 +173,14 @@ export function UploadCardRenderer({
|
|||||||
bottom={
|
bottom={
|
||||||
<>
|
<>
|
||||||
{fileItem.originalFile.type.startsWith('image') && (
|
{fileItem.originalFile.type.startsWith('image') && (
|
||||||
<ImagePreview fileItem={fileItem} onSpoiler={handleSpoiler} />
|
<MediaPreview fileItem={fileItem} onSpoiler={handleSpoiler}>
|
||||||
|
<PreviewImage fileItem={fileItem} />
|
||||||
|
</MediaPreview>
|
||||||
|
)}
|
||||||
|
{fileItem.originalFile.type.startsWith('video') && (
|
||||||
|
<MediaPreview fileItem={fileItem} onSpoiler={handleSpoiler}>
|
||||||
|
<PreviewVideo fileItem={fileItem} />
|
||||||
|
</MediaPreview>
|
||||||
)}
|
)}
|
||||||
{upload.status === UploadStatus.Idle && !fileSizeExceeded && (
|
{upload.status === UploadStatus.Idle && !fileSizeExceeded && (
|
||||||
<UploadCardProgress sentBytes={0} totalBytes={file.size} />
|
<UploadCardProgress sentBytes={0} totalBytes={file.size} />
|
||||||
|
|||||||
@@ -329,7 +329,7 @@ function LocalAddressesList({
|
|||||||
<Box shrink="No">
|
<Box shrink="No">
|
||||||
<Checkbox
|
<Checkbox
|
||||||
checked={selected}
|
checked={selected}
|
||||||
onChange={() => toggleSelect(alias)}
|
onClick={() => toggleSelect(alias)}
|
||||||
size="50"
|
size="50"
|
||||||
variant="Primary"
|
variant="Primary"
|
||||||
disabled={loading}
|
disabled={loading}
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ import { useKeyDown } from '../../hooks/useKeyDown';
|
|||||||
import { markAsRead } from '../../utils/notifications';
|
import { markAsRead } from '../../utils/notifications';
|
||||||
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
||||||
import { useRoomMembers } from '../../hooks/useRoomMembers';
|
import { useRoomMembers } from '../../hooks/useRoomMembers';
|
||||||
|
import { ThreadView } from './thread-view';
|
||||||
|
import { useActiveThread } from '../../state/hooks/roomToActiveThread';
|
||||||
|
|
||||||
export function Room() {
|
export function Room() {
|
||||||
const { eventId } = useParams();
|
const { eventId } = useParams();
|
||||||
@@ -25,6 +27,8 @@ export function Room() {
|
|||||||
const powerLevels = usePowerLevels(room);
|
const powerLevels = usePowerLevels(room);
|
||||||
const members = useRoomMembers(mx, room.roomId);
|
const members = useRoomMembers(mx, room.roomId);
|
||||||
|
|
||||||
|
const threadId = useActiveThread(room.roomId);
|
||||||
|
|
||||||
useKeyDown(
|
useKeyDown(
|
||||||
window,
|
window,
|
||||||
useCallback(
|
useCallback(
|
||||||
@@ -41,11 +45,19 @@ export function Room() {
|
|||||||
<PowerLevelsContextProvider value={powerLevels}>
|
<PowerLevelsContextProvider value={powerLevels}>
|
||||||
<Box grow="Yes">
|
<Box grow="Yes">
|
||||||
<RoomView room={room} eventId={eventId} />
|
<RoomView room={room} eventId={eventId} />
|
||||||
{screenSize === ScreenSize.Desktop && isDrawer && (
|
{threadId ? (
|
||||||
<>
|
<>
|
||||||
<Line variant="Background" direction="Vertical" size="300" />
|
<Line variant="Surface" direction="Vertical" size="300" />
|
||||||
<MembersDrawer key={room.roomId} room={room} members={members} />
|
<ThreadView threadId={threadId} />
|
||||||
</>
|
</>
|
||||||
|
) : (
|
||||||
|
screenSize === ScreenSize.Desktop &&
|
||||||
|
isDrawer && (
|
||||||
|
<>
|
||||||
|
<Line variant="Background" direction="Vertical" size="300" />
|
||||||
|
<MembersDrawer key={room.roomId} room={room} members={members} />
|
||||||
|
</>
|
||||||
|
)
|
||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
</PowerLevelsContextProvider>
|
</PowerLevelsContextProvider>
|
||||||
|
|||||||
@@ -116,6 +116,7 @@ import { useRoomCreators } from '../../hooks/useRoomCreators';
|
|||||||
import { useTheme } from '../../hooks/useTheme';
|
import { useTheme } from '../../hooks/useTheme';
|
||||||
import { useRoomCreatorsTag } from '../../hooks/useRoomCreatorsTag';
|
import { useRoomCreatorsTag } from '../../hooks/useRoomCreatorsTag';
|
||||||
import { usePowerLevelTags } from '../../hooks/usePowerLevelTags';
|
import { usePowerLevelTags } from '../../hooks/usePowerLevelTags';
|
||||||
|
import { useComposingCheck } from '../../hooks/useComposingCheck';
|
||||||
|
|
||||||
interface RoomInputProps {
|
interface RoomInputProps {
|
||||||
editor: Editor;
|
editor: Editor;
|
||||||
@@ -217,6 +218,8 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
|
|||||||
const dropZoneVisible = useFileDropZone(fileDropContainerRef, handleFiles);
|
const dropZoneVisible = useFileDropZone(fileDropContainerRef, handleFiles);
|
||||||
const [hideStickerBtn, setHideStickerBtn] = useState(document.body.clientWidth < 500);
|
const [hideStickerBtn, setHideStickerBtn] = useState(document.body.clientWidth < 500);
|
||||||
|
|
||||||
|
const isComposing = useComposingCheck();
|
||||||
|
|
||||||
useElementSizeObserver(
|
useElementSizeObserver(
|
||||||
useCallback(() => document.body, []),
|
useCallback(() => document.body, []),
|
||||||
useCallback((width) => setHideStickerBtn(width < 500), [])
|
useCallback((width) => setHideStickerBtn(width < 500), [])
|
||||||
@@ -380,7 +383,7 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
|
|||||||
(evt) => {
|
(evt) => {
|
||||||
if (
|
if (
|
||||||
(isKeyHotkey('mod+enter', evt) || (!enterForNewline && isKeyHotkey('enter', evt))) &&
|
(isKeyHotkey('mod+enter', evt) || (!enterForNewline && isKeyHotkey('enter', evt))) &&
|
||||||
!evt.nativeEvent.isComposing
|
!isComposing(evt)
|
||||||
) {
|
) {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
submit();
|
submit();
|
||||||
@@ -394,7 +397,7 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
|
|||||||
setReplyDraft(undefined);
|
setReplyDraft(undefined);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[submit, setReplyDraft, enterForNewline, autocompleteQuery]
|
[submit, setReplyDraft, enterForNewline, autocompleteQuery, isComposing]
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleKeyUp: KeyboardEventHandler = useCallback(
|
const handleKeyUp: KeyboardEventHandler = useCallback(
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ import {
|
|||||||
decryptAllTimelineEvent,
|
decryptAllTimelineEvent,
|
||||||
getEditedEvent,
|
getEditedEvent,
|
||||||
getEventReactions,
|
getEventReactions,
|
||||||
|
getEventThreadDetail,
|
||||||
getLatestEditableEvt,
|
getLatestEditableEvt,
|
||||||
getMemberDisplayName,
|
getMemberDisplayName,
|
||||||
getReactionContent,
|
getReactionContent,
|
||||||
@@ -126,6 +127,18 @@ import { useAccessiblePowerTagColors, useGetMemberPowerTag } from '../../hooks/u
|
|||||||
import { useTheme } from '../../hooks/useTheme';
|
import { useTheme } from '../../hooks/useTheme';
|
||||||
import { useRoomCreatorsTag } from '../../hooks/useRoomCreatorsTag';
|
import { useRoomCreatorsTag } from '../../hooks/useRoomCreatorsTag';
|
||||||
import { usePowerLevelTags } from '../../hooks/usePowerLevelTags';
|
import { usePowerLevelTags } from '../../hooks/usePowerLevelTags';
|
||||||
|
import { ThreadSelector, ThreadSelectorContainer } from './message/thread-selector';
|
||||||
|
import {
|
||||||
|
getEventIdAbsoluteIndex,
|
||||||
|
getFirstLinkedTimeline,
|
||||||
|
getLinkedTimelines,
|
||||||
|
getTimelineAndBaseIndex,
|
||||||
|
getTimelineEvent,
|
||||||
|
getTimelineRelativeIndex,
|
||||||
|
getTimelinesEventsCount,
|
||||||
|
timelineToEventsCount,
|
||||||
|
} from './utils';
|
||||||
|
import { useThreadSelector } from '../../state/hooks/roomToActiveThread';
|
||||||
|
|
||||||
const TimelineFloat = as<'div', css.TimelineFloatVariants>(
|
const TimelineFloat = as<'div', css.TimelineFloatVariants>(
|
||||||
({ position, className, ...props }, ref) => (
|
({ position, className, ...props }, ref) => (
|
||||||
@@ -150,79 +163,6 @@ const TimelineDivider = as<'div', { variant?: ContainerColor | 'Inherit' }>(
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
export const getLiveTimeline = (room: Room): EventTimeline =>
|
|
||||||
room.getUnfilteredTimelineSet().getLiveTimeline();
|
|
||||||
|
|
||||||
export const getEventTimeline = (room: Room, eventId: string): EventTimeline | undefined => {
|
|
||||||
const timelineSet = room.getUnfilteredTimelineSet();
|
|
||||||
return timelineSet.getTimelineForEvent(eventId) ?? undefined;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getFirstLinkedTimeline = (
|
|
||||||
timeline: EventTimeline,
|
|
||||||
direction: Direction
|
|
||||||
): EventTimeline => {
|
|
||||||
const linkedTm = timeline.getNeighbouringTimeline(direction);
|
|
||||||
if (!linkedTm) return timeline;
|
|
||||||
return getFirstLinkedTimeline(linkedTm, direction);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getLinkedTimelines = (timeline: EventTimeline): EventTimeline[] => {
|
|
||||||
const firstTimeline = getFirstLinkedTimeline(timeline, Direction.Backward);
|
|
||||||
const timelines: EventTimeline[] = [];
|
|
||||||
|
|
||||||
for (
|
|
||||||
let nextTimeline: EventTimeline | null = firstTimeline;
|
|
||||||
nextTimeline;
|
|
||||||
nextTimeline = nextTimeline.getNeighbouringTimeline(Direction.Forward)
|
|
||||||
) {
|
|
||||||
timelines.push(nextTimeline);
|
|
||||||
}
|
|
||||||
return timelines;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const timelineToEventsCount = (t: EventTimeline) => t.getEvents().length;
|
|
||||||
export const getTimelinesEventsCount = (timelines: EventTimeline[]): number => {
|
|
||||||
const timelineEventCountReducer = (count: number, tm: EventTimeline) =>
|
|
||||||
count + timelineToEventsCount(tm);
|
|
||||||
return timelines.reduce(timelineEventCountReducer, 0);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getTimelineAndBaseIndex = (
|
|
||||||
timelines: EventTimeline[],
|
|
||||||
index: number
|
|
||||||
): [EventTimeline | undefined, number] => {
|
|
||||||
let uptoTimelineLen = 0;
|
|
||||||
const timeline = timelines.find((t) => {
|
|
||||||
uptoTimelineLen += t.getEvents().length;
|
|
||||||
if (index < uptoTimelineLen) return true;
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
if (!timeline) return [undefined, 0];
|
|
||||||
return [timeline, uptoTimelineLen - timeline.getEvents().length];
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getTimelineRelativeIndex = (absoluteIndex: number, timelineBaseIndex: number) =>
|
|
||||||
absoluteIndex - timelineBaseIndex;
|
|
||||||
|
|
||||||
export const getTimelineEvent = (timeline: EventTimeline, index: number): MatrixEvent | undefined =>
|
|
||||||
timeline.getEvents()[index];
|
|
||||||
|
|
||||||
export const getEventIdAbsoluteIndex = (
|
|
||||||
timelines: EventTimeline[],
|
|
||||||
eventTimeline: EventTimeline,
|
|
||||||
eventId: string
|
|
||||||
): number | undefined => {
|
|
||||||
const timelineIndex = timelines.findIndex((t) => t === eventTimeline);
|
|
||||||
if (timelineIndex === -1) return undefined;
|
|
||||||
const eventIndex = eventTimeline.getEvents().findIndex((evt) => evt.getId() === eventId);
|
|
||||||
if (eventIndex === -1) return undefined;
|
|
||||||
const baseIndex = timelines
|
|
||||||
.slice(0, timelineIndex)
|
|
||||||
.reduce((accValue, timeline) => timeline.getEvents().length + accValue, 0);
|
|
||||||
return baseIndex + eventIndex;
|
|
||||||
};
|
|
||||||
|
|
||||||
type RoomTimelineProps = {
|
type RoomTimelineProps = {
|
||||||
room: Room;
|
room: Room;
|
||||||
eventId?: string;
|
eventId?: string;
|
||||||
@@ -232,6 +172,14 @@ type RoomTimelineProps = {
|
|||||||
|
|
||||||
const PAGINATION_LIMIT = 80;
|
const PAGINATION_LIMIT = 80;
|
||||||
|
|
||||||
|
export const getLiveTimeline = (room: Room): EventTimeline =>
|
||||||
|
room.getUnfilteredTimelineSet().getLiveTimeline();
|
||||||
|
|
||||||
|
export const getEventTimeline = (room: Room, eventId: string): EventTimeline | undefined => {
|
||||||
|
const timelineSet = room.getUnfilteredTimelineSet();
|
||||||
|
return timelineSet.getTimelineForEvent(eventId) ?? undefined;
|
||||||
|
};
|
||||||
|
|
||||||
type Timeline = {
|
type Timeline = {
|
||||||
linkedTimelines: EventTimeline[];
|
linkedTimelines: EventTimeline[];
|
||||||
range: ItemRange;
|
range: ItemRange;
|
||||||
@@ -482,6 +430,7 @@ export function RoomTimeline({ room, eventId, roomInputRef, editor }: RoomTimeli
|
|||||||
const spoilerClickHandler = useSpoilerClickHandler();
|
const spoilerClickHandler = useSpoilerClickHandler();
|
||||||
const openUserRoomProfile = useOpenUserRoomProfile();
|
const openUserRoomProfile = useOpenUserRoomProfile();
|
||||||
const space = useSpaceOptionally();
|
const space = useSpaceOptionally();
|
||||||
|
const handleThreadClick = useThreadSelector(room.roomId);
|
||||||
|
|
||||||
const imagePackRooms: Room[] = useImagePackRooms(room.roomId, roomToParents);
|
const imagePackRooms: Room[] = useImagePackRooms(room.roomId, roomToParents);
|
||||||
|
|
||||||
@@ -1014,6 +963,7 @@ export function RoomTimeline({ room, eventId, roomInputRef, editor }: RoomTimeli
|
|||||||
},
|
},
|
||||||
[editor]
|
[editor]
|
||||||
);
|
);
|
||||||
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const renderMatrixEvent = useMatrixEventRenderer<
|
const renderMatrixEvent = useMatrixEventRenderer<
|
||||||
@@ -1034,6 +984,7 @@ export function RoomTimeline({ room, eventId, roomInputRef, editor }: RoomTimeli
|
|||||||
const senderId = mEvent.getSender() ?? '';
|
const senderId = mEvent.getSender() ?? '';
|
||||||
const senderDisplayName =
|
const senderDisplayName =
|
||||||
getMemberDisplayName(room, senderId) ?? getMxIdLocalPart(senderId) ?? senderId;
|
getMemberDisplayName(room, senderId) ?? getMxIdLocalPart(senderId) ?? senderId;
|
||||||
|
const threadDetail = getEventThreadDetail(mEvent);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Message
|
<Message
|
||||||
@@ -1107,6 +1058,20 @@ export function RoomTimeline({ room, eventId, roomInputRef, editor }: RoomTimeli
|
|||||||
outlineAttachment={messageLayout === MessageLayout.Bubble}
|
outlineAttachment={messageLayout === MessageLayout.Bubble}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{threadDetail && (
|
||||||
|
<ThreadSelectorContainer>
|
||||||
|
<ThreadSelector
|
||||||
|
room={room}
|
||||||
|
threadId={mEventId}
|
||||||
|
threadDetail={threadDetail}
|
||||||
|
hour24Clock={hour24Clock}
|
||||||
|
dateFormatString={dateFormatString}
|
||||||
|
outlined={messageLayout === MessageLayout.Bubble}
|
||||||
|
onClick={handleThreadClick}
|
||||||
|
/>
|
||||||
|
</ThreadSelectorContainer>
|
||||||
|
)}
|
||||||
</Message>
|
</Message>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -79,9 +79,8 @@ export function RoomView({ room, eventId }: { room: Room; eventId?: string }) {
|
|||||||
useCallback(
|
useCallback(
|
||||||
(evt) => {
|
(evt) => {
|
||||||
if (editableActiveElement()) return;
|
if (editableActiveElement()) return;
|
||||||
// means some menu or modal window is open
|
const portalContainer = document.getElementById('portalContainer');
|
||||||
const lastNode = document.body.lastElementChild;
|
if (portalContainer && portalContainer.children.length > 0) {
|
||||||
if (lastNode && !lastNode.hasAttribute('data-last-node')) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (shouldFocusMessageField(evt) || isKeyHotkey('mod+v', evt)) {
|
if (shouldFocusMessageField(evt) || isKeyHotkey('mod+v', evt)) {
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ import { useRoomNavigate } from '../../hooks/useRoomNavigate';
|
|||||||
import { useRoomCreators } from '../../hooks/useRoomCreators';
|
import { useRoomCreators } from '../../hooks/useRoomCreators';
|
||||||
import { useRoomPermissions } from '../../hooks/useRoomPermissions';
|
import { useRoomPermissions } from '../../hooks/useRoomPermissions';
|
||||||
import { InviteUserPrompt } from '../../components/invite-user-prompt';
|
import { InviteUserPrompt } from '../../components/invite-user-prompt';
|
||||||
|
import { ThreadsMenu } from './threads-menu';
|
||||||
|
|
||||||
type RoomMenuProps = {
|
type RoomMenuProps = {
|
||||||
room: Room;
|
room: Room;
|
||||||
@@ -263,6 +264,7 @@ export function RoomViewHeader() {
|
|||||||
const space = useSpaceOptionally();
|
const space = useSpaceOptionally();
|
||||||
const [menuAnchor, setMenuAnchor] = useState<RectCords>();
|
const [menuAnchor, setMenuAnchor] = useState<RectCords>();
|
||||||
const [pinMenuAnchor, setPinMenuAnchor] = useState<RectCords>();
|
const [pinMenuAnchor, setPinMenuAnchor] = useState<RectCords>();
|
||||||
|
const [threadsMenuAnchor, setThreadsMenuAnchor] = useState<RectCords>();
|
||||||
const mDirects = useAtomValue(mDirectAtom);
|
const mDirects = useAtomValue(mDirectAtom);
|
||||||
|
|
||||||
const pinnedEvents = useRoomPinnedEvents(room);
|
const pinnedEvents = useRoomPinnedEvents(room);
|
||||||
@@ -295,6 +297,10 @@ export function RoomViewHeader() {
|
|||||||
setPinMenuAnchor(evt.currentTarget.getBoundingClientRect());
|
setPinMenuAnchor(evt.currentTarget.getBoundingClientRect());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleOpenThreadsMenu: MouseEventHandler<HTMLButtonElement> = (evt) => {
|
||||||
|
setThreadsMenuAnchor(evt.currentTarget.getBoundingClientRect());
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PageHeader balance={screenSize === ScreenSize.Mobile}>
|
<PageHeader balance={screenSize === ScreenSize.Mobile}>
|
||||||
<Box grow="Yes" gap="300">
|
<Box grow="Yes" gap="300">
|
||||||
@@ -424,6 +430,27 @@ export function RoomViewHeader() {
|
|||||||
</IconButton>
|
</IconButton>
|
||||||
)}
|
)}
|
||||||
</TooltipProvider>
|
</TooltipProvider>
|
||||||
|
|
||||||
|
<TooltipProvider
|
||||||
|
position="Bottom"
|
||||||
|
offset={4}
|
||||||
|
tooltip={
|
||||||
|
<Tooltip>
|
||||||
|
<Text>My Threads</Text>
|
||||||
|
</Tooltip>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{(triggerRef) => (
|
||||||
|
<IconButton
|
||||||
|
style={{ position: 'relative' }}
|
||||||
|
onClick={handleOpenThreadsMenu}
|
||||||
|
ref={triggerRef}
|
||||||
|
aria-pressed={!!threadsMenuAnchor}
|
||||||
|
>
|
||||||
|
<Icon size="400" src={Icons.Thread} filled={!!threadsMenuAnchor} />
|
||||||
|
</IconButton>
|
||||||
|
)}
|
||||||
|
</TooltipProvider>
|
||||||
<PopOut
|
<PopOut
|
||||||
anchor={pinMenuAnchor}
|
anchor={pinMenuAnchor}
|
||||||
position="Bottom"
|
position="Bottom"
|
||||||
@@ -443,6 +470,25 @@ export function RoomViewHeader() {
|
|||||||
</FocusTrap>
|
</FocusTrap>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
<PopOut
|
||||||
|
anchor={threadsMenuAnchor}
|
||||||
|
position="Bottom"
|
||||||
|
content={
|
||||||
|
<FocusTrap
|
||||||
|
focusTrapOptions={{
|
||||||
|
initialFocus: false,
|
||||||
|
returnFocusOnDeactivate: false,
|
||||||
|
onDeactivate: () => setThreadsMenuAnchor(undefined),
|
||||||
|
clickOutsideDeactivates: true,
|
||||||
|
isKeyForward: (evt: KeyboardEvent) => evt.key === 'ArrowDown',
|
||||||
|
isKeyBackward: (evt: KeyboardEvent) => evt.key === 'ArrowUp',
|
||||||
|
escapeDeactivates: stopPropagation,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<ThreadsMenu room={room} requestClose={() => setThreadsMenuAnchor(undefined)} />
|
||||||
|
</FocusTrap>
|
||||||
|
}
|
||||||
|
/>
|
||||||
{screenSize === ScreenSize.Desktop && (
|
{screenSize === ScreenSize.Desktop && (
|
||||||
<TooltipProvider
|
<TooltipProvider
|
||||||
position="Bottom"
|
position="Bottom"
|
||||||
|
|||||||
@@ -723,6 +723,7 @@ export const Message = as<'div', MessageProps>(
|
|||||||
const mx = useMatrixClient();
|
const mx = useMatrixClient();
|
||||||
const useAuthentication = useMediaAuthentication();
|
const useAuthentication = useMediaAuthentication();
|
||||||
const senderId = mEvent.getSender() ?? '';
|
const senderId = mEvent.getSender() ?? '';
|
||||||
|
|
||||||
const [hover, setHover] = useState(false);
|
const [hover, setHover] = useState(false);
|
||||||
const { hoverProps } = useHover({ onHoverChange: setHover });
|
const { hoverProps } = useHover({ onHoverChange: setHover });
|
||||||
const { focusWithinProps } = useFocusWithin({ onFocusWithinChange: setHover });
|
const { focusWithinProps } = useFocusWithin({ onFocusWithinChange: setHover });
|
||||||
@@ -790,7 +791,9 @@ export const Message = as<'div', MessageProps>(
|
|||||||
);
|
);
|
||||||
|
|
||||||
const avatarJSX = !collapse && messageLayout !== MessageLayout.Compact && (
|
const avatarJSX = !collapse && messageLayout !== MessageLayout.Compact && (
|
||||||
<AvatarBase>
|
<AvatarBase
|
||||||
|
className={messageLayout === MessageLayout.Bubble ? css.BubbleAvatarBase : undefined}
|
||||||
|
>
|
||||||
<Avatar
|
<Avatar
|
||||||
className={css.MessageAvatar}
|
className={css.MessageAvatar}
|
||||||
as="button"
|
as="button"
|
||||||
@@ -875,7 +878,9 @@ export const Message = as<'div', MessageProps>(
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<MessageBase
|
<MessageBase
|
||||||
className={classNames(css.MessageBase, className)}
|
className={classNames(css.MessageBase, className, {
|
||||||
|
[css.MessageBaseBubbleCollapsed]: messageLayout === MessageLayout.Bubble && collapse,
|
||||||
|
})}
|
||||||
tabIndex={0}
|
tabIndex={0}
|
||||||
space={messageSpacing}
|
space={messageSpacing}
|
||||||
collapse={collapse}
|
collapse={collapse}
|
||||||
@@ -1132,8 +1137,7 @@ export const Message = as<'div', MessageProps>(
|
|||||||
</CompactLayout>
|
</CompactLayout>
|
||||||
)}
|
)}
|
||||||
{messageLayout === MessageLayout.Bubble && (
|
{messageLayout === MessageLayout.Bubble && (
|
||||||
<BubbleLayout before={avatarJSX} onContextMenu={handleContextMenu}>
|
<BubbleLayout before={avatarJSX} header={headerJSX} onContextMenu={handleContextMenu}>
|
||||||
{headerJSX}
|
|
||||||
{msgContentJSX}
|
{msgContentJSX}
|
||||||
</BubbleLayout>
|
</BubbleLayout>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ import { AsyncStatus, useAsyncCallback } from '../../../hooks/useAsyncCallback';
|
|||||||
import { useMatrixClient } from '../../../hooks/useMatrixClient';
|
import { useMatrixClient } from '../../../hooks/useMatrixClient';
|
||||||
import { getEditedEvent, getMentionContent, trimReplyFromFormattedBody } from '../../../utils/room';
|
import { getEditedEvent, getMentionContent, trimReplyFromFormattedBody } from '../../../utils/room';
|
||||||
import { mobileOrTablet } from '../../../utils/user-agent';
|
import { mobileOrTablet } from '../../../utils/user-agent';
|
||||||
|
import { useComposingCheck } from '../../../hooks/useComposingCheck';
|
||||||
|
|
||||||
type MessageEditorProps = {
|
type MessageEditorProps = {
|
||||||
roomId: string;
|
roomId: string;
|
||||||
@@ -69,6 +70,7 @@ export const MessageEditor = as<'div', MessageEditorProps>(
|
|||||||
const [globalToolbar] = useSetting(settingsAtom, 'editorToolbar');
|
const [globalToolbar] = useSetting(settingsAtom, 'editorToolbar');
|
||||||
const [isMarkdown] = useSetting(settingsAtom, 'isMarkdown');
|
const [isMarkdown] = useSetting(settingsAtom, 'isMarkdown');
|
||||||
const [toolbar, setToolbar] = useState(globalToolbar);
|
const [toolbar, setToolbar] = useState(globalToolbar);
|
||||||
|
const isComposing = useComposingCheck();
|
||||||
|
|
||||||
const [autocompleteQuery, setAutocompleteQuery] =
|
const [autocompleteQuery, setAutocompleteQuery] =
|
||||||
useState<AutocompleteQuery<AutocompletePrefix>>();
|
useState<AutocompleteQuery<AutocompletePrefix>>();
|
||||||
@@ -163,7 +165,10 @@ export const MessageEditor = as<'div', MessageEditorProps>(
|
|||||||
|
|
||||||
const handleKeyDown: KeyboardEventHandler = useCallback(
|
const handleKeyDown: KeyboardEventHandler = useCallback(
|
||||||
(evt) => {
|
(evt) => {
|
||||||
if ((isKeyHotkey('mod+enter', evt) || (!enterForNewline && isKeyHotkey('enter', evt))) && !evt.nativeEvent.isComposing) {
|
if (
|
||||||
|
(isKeyHotkey('mod+enter', evt) || (!enterForNewline && isKeyHotkey('enter', evt))) &&
|
||||||
|
!isComposing(evt)
|
||||||
|
) {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
handleSave();
|
handleSave();
|
||||||
}
|
}
|
||||||
@@ -172,7 +177,7 @@ export const MessageEditor = as<'div', MessageEditorProps>(
|
|||||||
onCancel();
|
onCancel();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[onCancel, handleSave, enterForNewline]
|
[onCancel, handleSave, enterForNewline, isComposing]
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleKeyUp: KeyboardEventHandler = useCallback(
|
const handleKeyUp: KeyboardEventHandler = useCallback(
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ import { DefaultReset, config, toRem } from 'folds';
|
|||||||
export const MessageBase = style({
|
export const MessageBase = style({
|
||||||
position: 'relative',
|
position: 'relative',
|
||||||
});
|
});
|
||||||
|
export const MessageBaseBubbleCollapsed = style({
|
||||||
|
paddingTop: 0,
|
||||||
|
});
|
||||||
|
|
||||||
export const MessageOptionsBase = style([
|
export const MessageOptionsBase = style([
|
||||||
DefaultReset,
|
DefaultReset,
|
||||||
@@ -21,6 +24,10 @@ export const MessageOptionsBar = style([
|
|||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
export const BubbleAvatarBase = style({
|
||||||
|
paddingTop: 0,
|
||||||
|
});
|
||||||
|
|
||||||
export const MessageAvatar = style({
|
export const MessageAvatar = style({
|
||||||
cursor: 'pointer',
|
cursor: 'pointer',
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -0,0 +1,83 @@
|
|||||||
|
import { Box, Icon, Icons, Line, Text } from 'folds';
|
||||||
|
import React, { ReactNode } from 'react';
|
||||||
|
import classNames from 'classnames';
|
||||||
|
import { IThreadBundledRelationship, Room } from 'matrix-js-sdk';
|
||||||
|
import * as css from './styles.css';
|
||||||
|
import { getMemberDisplayName } from '../../../../utils/room';
|
||||||
|
import { getMxIdLocalPart } from '../../../../utils/matrix';
|
||||||
|
import { Time } from '../../../../components/message';
|
||||||
|
|
||||||
|
export function ThreadSelectorContainer({ children }: { children: ReactNode }) {
|
||||||
|
return <Box className={css.ThreadSelectorContainer}>{children}</Box>;
|
||||||
|
}
|
||||||
|
|
||||||
|
type ThreadSelectorProps = {
|
||||||
|
room: Room;
|
||||||
|
threadId: string;
|
||||||
|
threadDetail: IThreadBundledRelationship;
|
||||||
|
outlined?: boolean;
|
||||||
|
hour24Clock: boolean;
|
||||||
|
dateFormatString: string;
|
||||||
|
onClick?: (threadId: string) => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
export function ThreadSelector({
|
||||||
|
room,
|
||||||
|
threadId,
|
||||||
|
threadDetail,
|
||||||
|
outlined,
|
||||||
|
hour24Clock,
|
||||||
|
dateFormatString,
|
||||||
|
onClick,
|
||||||
|
}: ThreadSelectorProps) {
|
||||||
|
const latestEvent = threadDetail.latest_event;
|
||||||
|
|
||||||
|
const latestSenderId = latestEvent.sender;
|
||||||
|
const latestDisplayName =
|
||||||
|
getMemberDisplayName(room, latestSenderId) ??
|
||||||
|
getMxIdLocalPart(latestSenderId) ??
|
||||||
|
latestSenderId;
|
||||||
|
|
||||||
|
const latestEventTs = latestEvent.origin_server_ts;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box
|
||||||
|
as="button"
|
||||||
|
type="button"
|
||||||
|
className={classNames(css.ThreadSelector, outlined && css.ThreadSectorOutlined)}
|
||||||
|
alignItems="Center"
|
||||||
|
gap="300"
|
||||||
|
onClick={() => onClick?.(threadId)}
|
||||||
|
>
|
||||||
|
<Box className={css.ThreadRepliesCount} shrink="No" alignItems="Center" gap="200">
|
||||||
|
<Icon size="100" src={Icons.Thread} filled />
|
||||||
|
<Text size="L400">
|
||||||
|
{threadDetail.count} {threadDetail.count === 1 ? 'Reply' : 'Replies'}
|
||||||
|
</Text>
|
||||||
|
</Box>
|
||||||
|
{latestSenderId && (
|
||||||
|
<>
|
||||||
|
<Line
|
||||||
|
className={css.ThreadSelectorDivider}
|
||||||
|
direction="Vertical"
|
||||||
|
variant="SurfaceVariant"
|
||||||
|
/>
|
||||||
|
<Box gap="200" alignItems="Inherit">
|
||||||
|
<Text size="T200" truncate>
|
||||||
|
<span>Last reply by </span>
|
||||||
|
<b>{latestDisplayName}</b>
|
||||||
|
<span> — </span>
|
||||||
|
<Time
|
||||||
|
hour24Clock={hour24Clock}
|
||||||
|
dateFormatString={dateFormatString}
|
||||||
|
ts={latestEventTs}
|
||||||
|
inheritPriority
|
||||||
|
/>
|
||||||
|
</Text>
|
||||||
|
<Icon size="100" src={Icons.ChevronRight} />
|
||||||
|
</Box>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
}
|
||||||
1
src/app/features/room/message/thread-selector/index.ts
Normal file
1
src/app/features/room/message/thread-selector/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export * from './ThreadSelector';
|
||||||
37
src/app/features/room/message/thread-selector/styles.css.ts
Normal file
37
src/app/features/room/message/thread-selector/styles.css.ts
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
import { style } from '@vanilla-extract/css';
|
||||||
|
import { color, config, toRem } from 'folds';
|
||||||
|
import { ContainerColor } from '../../../../styles/ContainerColor.css';
|
||||||
|
|
||||||
|
export const ThreadSelectorContainer = style({
|
||||||
|
marginTop: config.space.S200,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const ThreadSelector = style([
|
||||||
|
ContainerColor({ variant: 'SurfaceVariant' }),
|
||||||
|
{
|
||||||
|
padding: config.space.S200,
|
||||||
|
borderRadius: config.radii.R400,
|
||||||
|
cursor: 'pointer',
|
||||||
|
|
||||||
|
selectors: {
|
||||||
|
'&:hover, &:focus-visible': {
|
||||||
|
backgroundColor: color.SurfaceVariant.ContainerHover,
|
||||||
|
},
|
||||||
|
'&:active': {
|
||||||
|
backgroundColor: color.SurfaceVariant.ContainerActive,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
export const ThreadSectorOutlined = style({
|
||||||
|
borderWidth: config.borderWidth.B300,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const ThreadSelectorDivider = style({
|
||||||
|
height: toRem(16),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const ThreadRepliesCount = style({
|
||||||
|
color: color.Primary.Main,
|
||||||
|
});
|
||||||
@@ -82,7 +82,7 @@ export const getVideoMsgContent = async (
|
|||||||
item: TUploadItem,
|
item: TUploadItem,
|
||||||
mxc: string
|
mxc: string
|
||||||
): Promise<IContent> => {
|
): Promise<IContent> => {
|
||||||
const { file, originalFile, encInfo } = item;
|
const { file, originalFile, encInfo, metadata } = item;
|
||||||
|
|
||||||
const [videoError, videoEl] = await to(loadVideoElement(getVideoFileUrl(originalFile)));
|
const [videoError, videoEl] = await to(loadVideoElement(getVideoFileUrl(originalFile)));
|
||||||
if (videoError) console.warn(videoError);
|
if (videoError) console.warn(videoError);
|
||||||
@@ -91,6 +91,7 @@ export const getVideoMsgContent = async (
|
|||||||
msgtype: MsgType.Video,
|
msgtype: MsgType.Video,
|
||||||
filename: file.name,
|
filename: file.name,
|
||||||
body: file.name,
|
body: file.name,
|
||||||
|
[MATRIX_SPOILER_PROPERTY_NAME]: metadata.markedAsSpoiler,
|
||||||
};
|
};
|
||||||
if (videoEl) {
|
if (videoEl) {
|
||||||
const [thumbError, thumbContent] = await to(
|
const [thumbError, thumbContent] = await to(
|
||||||
|
|||||||
79
src/app/features/room/thread-view/ThreadView.tsx
Normal file
79
src/app/features/room/thread-view/ThreadView.tsx
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { Box, Icon, IconButton, Icons, Scroll, Text, Tooltip, TooltipProvider } from 'folds';
|
||||||
|
import classNames from 'classnames';
|
||||||
|
import FocusTrap from 'focus-trap-react';
|
||||||
|
import { Page, PageHeader } from '../../../components/page';
|
||||||
|
import * as css from './styles.css';
|
||||||
|
import { useRoom } from '../../../hooks/useRoom';
|
||||||
|
import { useThreadClose } from '../../../state/hooks/roomToActiveThread';
|
||||||
|
import { ScreenSize, useScreenSizeContext } from '../../../hooks/useScreenSize';
|
||||||
|
|
||||||
|
type ThreadViewProps = {
|
||||||
|
threadId: string;
|
||||||
|
};
|
||||||
|
export function ThreadView({ threadId }: ThreadViewProps) {
|
||||||
|
const room = useRoom();
|
||||||
|
const screenSize = useScreenSizeContext();
|
||||||
|
const floating = screenSize !== ScreenSize.Desktop;
|
||||||
|
|
||||||
|
const closeThread = useThreadClose(room.roomId);
|
||||||
|
|
||||||
|
const thread = room.getThread(threadId);
|
||||||
|
const events = thread?.events ?? [];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<FocusTrap
|
||||||
|
paused={!floating}
|
||||||
|
focusTrapOptions={{
|
||||||
|
initialFocus: false,
|
||||||
|
clickOutsideDeactivates: true,
|
||||||
|
onDeactivate: floating ? closeThread : undefined,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Page
|
||||||
|
className={classNames(css.ThreadView, {
|
||||||
|
[css.ThreadViewFloating]: floating,
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
<PageHeader>
|
||||||
|
<Box grow="Yes" alignItems="Center" gap="200">
|
||||||
|
<Box grow="Yes">
|
||||||
|
<Text size="H5" truncate>
|
||||||
|
Thread
|
||||||
|
</Text>
|
||||||
|
</Box>
|
||||||
|
<Box shrink="No" alignItems="Center">
|
||||||
|
<TooltipProvider
|
||||||
|
position="Bottom"
|
||||||
|
align="End"
|
||||||
|
offset={4}
|
||||||
|
tooltip={
|
||||||
|
<Tooltip>
|
||||||
|
<Text>Close</Text>
|
||||||
|
</Tooltip>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{(triggerRef) => (
|
||||||
|
<IconButton ref={triggerRef} variant="Surface" onClick={closeThread}>
|
||||||
|
<Icon src={Icons.Cross} />
|
||||||
|
</IconButton>
|
||||||
|
)}
|
||||||
|
</TooltipProvider>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
</PageHeader>
|
||||||
|
<Box grow="Yes" direction="Column">
|
||||||
|
<Scroll visibility="Hover" hideTrack>
|
||||||
|
<div>
|
||||||
|
{events.map((mEvent) => (
|
||||||
|
<p style={{ padding: `8px 16px` }} key={mEvent.getId()}>
|
||||||
|
{mEvent.sender?.name}: {mEvent.getContent().body}
|
||||||
|
</p>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</Scroll>
|
||||||
|
</Box>
|
||||||
|
</Page>
|
||||||
|
</FocusTrap>
|
||||||
|
);
|
||||||
|
}
|
||||||
1
src/app/features/room/thread-view/index.tsx
Normal file
1
src/app/features/room/thread-view/index.tsx
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export * from './ThreadView';
|
||||||
21
src/app/features/room/thread-view/styles.css.ts
Normal file
21
src/app/features/room/thread-view/styles.css.ts
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import { style } from '@vanilla-extract/css';
|
||||||
|
import { config, toRem } from 'folds';
|
||||||
|
|
||||||
|
export const ThreadView = style({
|
||||||
|
width: toRem(456),
|
||||||
|
flexShrink: 0,
|
||||||
|
flexGrow: 0,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const ThreadViewFloating = style({
|
||||||
|
position: 'absolute',
|
||||||
|
right: 0,
|
||||||
|
top: 0,
|
||||||
|
bottom: 0,
|
||||||
|
zIndex: 1,
|
||||||
|
|
||||||
|
maxWidth: toRem(456),
|
||||||
|
flexShrink: 1,
|
||||||
|
width: '100vw',
|
||||||
|
boxShadow: config.shadow.E400,
|
||||||
|
});
|
||||||
32
src/app/features/room/threads-menu/ThreadsError.tsx
Normal file
32
src/app/features/room/threads-menu/ThreadsError.tsx
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { Box, Icon, Icons, toRem, Text, config } from 'folds';
|
||||||
|
import { ContainerColor } from '../../../styles/ContainerColor.css';
|
||||||
|
import { BreakWord } from '../../../styles/Text.css';
|
||||||
|
|
||||||
|
export function ThreadsError({ error }: { error: Error }) {
|
||||||
|
return (
|
||||||
|
<Box
|
||||||
|
className={ContainerColor({ variant: 'SurfaceVariant' })}
|
||||||
|
style={{
|
||||||
|
marginBottom: config.space.S200,
|
||||||
|
padding: `${config.space.S700} ${config.space.S400} ${toRem(60)}`,
|
||||||
|
borderRadius: config.radii.R300,
|
||||||
|
}}
|
||||||
|
grow="Yes"
|
||||||
|
direction="Column"
|
||||||
|
gap="400"
|
||||||
|
justifyContent="Center"
|
||||||
|
alignItems="Center"
|
||||||
|
>
|
||||||
|
<Icon src={Icons.Warning} size="600" />
|
||||||
|
<Box style={{ maxWidth: toRem(300) }} direction="Column" gap="200" alignItems="Center">
|
||||||
|
<Text size="H4" align="Center">
|
||||||
|
{error.name}
|
||||||
|
</Text>
|
||||||
|
<Text className={BreakWord} size="T400" align="Center">
|
||||||
|
{error.message}
|
||||||
|
</Text>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
}
|
||||||
23
src/app/features/room/threads-menu/ThreadsLoading.tsx
Normal file
23
src/app/features/room/threads-menu/ThreadsLoading.tsx
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import { Box, config, Spinner } from 'folds';
|
||||||
|
import React from 'react';
|
||||||
|
import { ContainerColor } from '../../../styles/ContainerColor.css';
|
||||||
|
|
||||||
|
export function ThreadsLoading() {
|
||||||
|
return (
|
||||||
|
<Box
|
||||||
|
className={ContainerColor({ variant: 'SurfaceVariant' })}
|
||||||
|
style={{
|
||||||
|
marginBottom: config.space.S200,
|
||||||
|
padding: config.space.S700,
|
||||||
|
borderRadius: config.radii.R300,
|
||||||
|
}}
|
||||||
|
grow="Yes"
|
||||||
|
direction="Column"
|
||||||
|
gap="400"
|
||||||
|
justifyContent="Center"
|
||||||
|
alignItems="Center"
|
||||||
|
>
|
||||||
|
<Spinner variant="Secondary" />
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
}
|
||||||
18
src/app/features/room/threads-menu/ThreadsMenu.css.ts
Normal file
18
src/app/features/room/threads-menu/ThreadsMenu.css.ts
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import { style } from '@vanilla-extract/css';
|
||||||
|
import { config, toRem } from 'folds';
|
||||||
|
|
||||||
|
export const ThreadsMenu = style({
|
||||||
|
display: 'flex',
|
||||||
|
maxWidth: toRem(548),
|
||||||
|
width: '100vw',
|
||||||
|
maxHeight: '90vh',
|
||||||
|
});
|
||||||
|
|
||||||
|
export const ThreadsMenuHeader = style({
|
||||||
|
paddingLeft: config.space.S400,
|
||||||
|
paddingRight: config.space.S200,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const ThreadsMenuContent = style({
|
||||||
|
paddingLeft: config.space.S200,
|
||||||
|
});
|
||||||
99
src/app/features/room/threads-menu/ThreadsMenu.tsx
Normal file
99
src/app/features/room/threads-menu/ThreadsMenu.tsx
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
/* eslint-disable react/destructuring-assignment */
|
||||||
|
import React, { forwardRef, useMemo } from 'react';
|
||||||
|
import { EventTimelineSet, Room } from 'matrix-js-sdk';
|
||||||
|
import { Box, config, Header, Icon, IconButton, Icons, Menu, Scroll, Text, toRem } from 'folds';
|
||||||
|
import * as css from './ThreadsMenu.css';
|
||||||
|
import { ContainerColor } from '../../../styles/ContainerColor.css';
|
||||||
|
import { useRoomMyThreads } from '../../../hooks/useRoomThreads';
|
||||||
|
import { AsyncStatus } from '../../../hooks/useAsyncCallback';
|
||||||
|
import { getLinkedTimelines, getTimelinesEventsCount } from '../utils';
|
||||||
|
import { ThreadsTimeline } from './ThreadsTimeline';
|
||||||
|
import { ThreadsLoading } from './ThreadsLoading';
|
||||||
|
import { ThreadsError } from './ThreadsError';
|
||||||
|
|
||||||
|
const getTimelines = (timelineSet: EventTimelineSet) => {
|
||||||
|
const liveTimeline = timelineSet.getLiveTimeline();
|
||||||
|
const linkedTimelines = getLinkedTimelines(liveTimeline);
|
||||||
|
|
||||||
|
return linkedTimelines;
|
||||||
|
};
|
||||||
|
|
||||||
|
function NoThreads() {
|
||||||
|
return (
|
||||||
|
<Box
|
||||||
|
className={ContainerColor({ variant: 'SurfaceVariant' })}
|
||||||
|
style={{
|
||||||
|
marginBottom: config.space.S200,
|
||||||
|
padding: `${config.space.S700} ${config.space.S400} ${toRem(60)}`,
|
||||||
|
borderRadius: config.radii.R300,
|
||||||
|
}}
|
||||||
|
grow="Yes"
|
||||||
|
direction="Column"
|
||||||
|
gap="400"
|
||||||
|
justifyContent="Center"
|
||||||
|
alignItems="Center"
|
||||||
|
>
|
||||||
|
<Icon src={Icons.Thread} size="600" />
|
||||||
|
<Box style={{ maxWidth: toRem(300) }} direction="Column" gap="200" alignItems="Center">
|
||||||
|
<Text size="H4" align="Center">
|
||||||
|
No Threads Yet
|
||||||
|
</Text>
|
||||||
|
<Text size="T400" align="Center">
|
||||||
|
Threads you’re participating in will appear here.
|
||||||
|
</Text>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
type ThreadsMenuProps = {
|
||||||
|
room: Room;
|
||||||
|
requestClose: () => void;
|
||||||
|
};
|
||||||
|
export const ThreadsMenu = forwardRef<HTMLDivElement, ThreadsMenuProps>(
|
||||||
|
({ room, requestClose }, ref) => {
|
||||||
|
const threadsState = useRoomMyThreads(room);
|
||||||
|
const threadsTimelineSet =
|
||||||
|
threadsState.status === AsyncStatus.Success ? threadsState.data : undefined;
|
||||||
|
|
||||||
|
const linkedTimelines = useMemo(() => {
|
||||||
|
if (!threadsTimelineSet) return undefined;
|
||||||
|
return getTimelines(threadsTimelineSet);
|
||||||
|
}, [threadsTimelineSet]);
|
||||||
|
|
||||||
|
const hasEvents = linkedTimelines && getTimelinesEventsCount(linkedTimelines) > 0;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Menu ref={ref} className={css.ThreadsMenu}>
|
||||||
|
<Box grow="Yes" direction="Column">
|
||||||
|
<Header className={css.ThreadsMenuHeader} size="500">
|
||||||
|
<Box grow="Yes">
|
||||||
|
<Text size="H5">My Threads</Text>
|
||||||
|
</Box>
|
||||||
|
<Box shrink="No">
|
||||||
|
<IconButton size="300" onClick={requestClose} radii="300">
|
||||||
|
<Icon src={Icons.Cross} size="400" />
|
||||||
|
</IconButton>
|
||||||
|
</Box>
|
||||||
|
</Header>
|
||||||
|
<Box grow="Yes">
|
||||||
|
{threadsState.status === AsyncStatus.Success && hasEvents ? (
|
||||||
|
<ThreadsTimeline timelines={linkedTimelines} requestClose={requestClose} />
|
||||||
|
) : (
|
||||||
|
<Scroll size="300" hideTrack visibility="Hover">
|
||||||
|
<Box className={css.ThreadsMenuContent} direction="Column" gap="100">
|
||||||
|
{(threadsState.status === AsyncStatus.Loading ||
|
||||||
|
threadsState.status === AsyncStatus.Idle) && <ThreadsLoading />}
|
||||||
|
{threadsState.status === AsyncStatus.Success && !hasEvents && <NoThreads />}
|
||||||
|
{threadsState.status === AsyncStatus.Error && (
|
||||||
|
<ThreadsError error={threadsState.error} />
|
||||||
|
)}
|
||||||
|
</Box>
|
||||||
|
</Scroll>
|
||||||
|
)}
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
</Menu>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
488
src/app/features/room/threads-menu/ThreadsTimeline.tsx
Normal file
488
src/app/features/room/threads-menu/ThreadsTimeline.tsx
Normal file
@@ -0,0 +1,488 @@
|
|||||||
|
/* eslint-disable react/destructuring-assignment */
|
||||||
|
import React, { MouseEventHandler, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||||
|
import { Direction, EventTimeline, MatrixEvent, Room } from 'matrix-js-sdk';
|
||||||
|
import { Avatar, Box, Chip, config, Icon, Icons, Scroll, Text } from 'folds';
|
||||||
|
import { Opts as LinkifyOpts } from 'linkifyjs';
|
||||||
|
import { HTMLReactParserOptions } from 'html-react-parser';
|
||||||
|
import { useVirtualizer } from '@tanstack/react-virtual';
|
||||||
|
import { SequenceCard } from '../../../components/sequence-card';
|
||||||
|
import { useMediaAuthentication } from '../../../hooks/useMediaAuthentication';
|
||||||
|
import {
|
||||||
|
AvatarBase,
|
||||||
|
ImageContent,
|
||||||
|
MessageNotDecryptedContent,
|
||||||
|
MessageUnsupportedContent,
|
||||||
|
ModernLayout,
|
||||||
|
MSticker,
|
||||||
|
RedactedContent,
|
||||||
|
Reply,
|
||||||
|
Time,
|
||||||
|
Username,
|
||||||
|
UsernameBold,
|
||||||
|
} from '../../../components/message';
|
||||||
|
import { UserAvatar } from '../../../components/user-avatar';
|
||||||
|
import { getMxIdLocalPart, mxcUrlToHttp } from '../../../utils/matrix';
|
||||||
|
import { useMatrixClient } from '../../../hooks/useMatrixClient';
|
||||||
|
import {
|
||||||
|
getEditedEvent,
|
||||||
|
getEventThreadDetail,
|
||||||
|
getMemberAvatarMxc,
|
||||||
|
getMemberDisplayName,
|
||||||
|
} from '../../../utils/room';
|
||||||
|
import { GetContentCallback, MessageEvent } from '../../../../types/matrix/room';
|
||||||
|
import { useMentionClickHandler } from '../../../hooks/useMentionClickHandler';
|
||||||
|
import { useSpoilerClickHandler } from '../../../hooks/useSpoilerClickHandler';
|
||||||
|
import {
|
||||||
|
factoryRenderLinkifyWithMention,
|
||||||
|
getReactCustomHtmlParser,
|
||||||
|
LINKIFY_OPTS,
|
||||||
|
makeMentionCustomProps,
|
||||||
|
renderMatrixMention,
|
||||||
|
} from '../../../plugins/react-custom-html-parser';
|
||||||
|
import { RenderMatrixEvent, useMatrixEventRenderer } from '../../../hooks/useMatrixEventRenderer';
|
||||||
|
import { RenderMessageContent } from '../../../components/RenderMessageContent';
|
||||||
|
import { useSetting } from '../../../state/hooks/settings';
|
||||||
|
import { settingsAtom } from '../../../state/settings';
|
||||||
|
import * as customHtmlCss from '../../../styles/CustomHtml.css';
|
||||||
|
import { EncryptedContent } from '../message';
|
||||||
|
import { Image } from '../../../components/media';
|
||||||
|
import { ImageViewer } from '../../../components/image-viewer';
|
||||||
|
import { useRoomNavigate } from '../../../hooks/useRoomNavigate';
|
||||||
|
import { usePowerLevelsContext } from '../../../hooks/usePowerLevels';
|
||||||
|
import { usePowerLevelTags } from '../../../hooks/usePowerLevelTags';
|
||||||
|
import { useTheme } from '../../../hooks/useTheme';
|
||||||
|
import { PowerIcon } from '../../../components/power';
|
||||||
|
import colorMXID from '../../../../util/colorMXID';
|
||||||
|
import { useIsDirectRoom, useRoom } from '../../../hooks/useRoom';
|
||||||
|
import { useRoomCreators } from '../../../hooks/useRoomCreators';
|
||||||
|
import {
|
||||||
|
GetMemberPowerTag,
|
||||||
|
getPowerTagIconSrc,
|
||||||
|
useAccessiblePowerTagColors,
|
||||||
|
useGetMemberPowerTag,
|
||||||
|
} from '../../../hooks/useMemberPowerTag';
|
||||||
|
import { useRoomCreatorsTag } from '../../../hooks/useRoomCreatorsTag';
|
||||||
|
import { ThreadSelector, ThreadSelectorContainer } from '../message/thread-selector';
|
||||||
|
import {
|
||||||
|
getTimelineAndBaseIndex,
|
||||||
|
getTimelineEvent,
|
||||||
|
getTimelineRelativeIndex,
|
||||||
|
getTimelinesEventsCount,
|
||||||
|
} from '../utils';
|
||||||
|
import { ThreadsLoading } from './ThreadsLoading';
|
||||||
|
import { VirtualTile } from '../../../components/virtualizer';
|
||||||
|
import { useAlive } from '../../../hooks/useAlive';
|
||||||
|
import * as css from './ThreadsMenu.css';
|
||||||
|
|
||||||
|
type ThreadMessageProps = {
|
||||||
|
room: Room;
|
||||||
|
event: MatrixEvent;
|
||||||
|
renderContent: RenderMatrixEvent<[string, MatrixEvent, string, GetContentCallback]>;
|
||||||
|
onOpen: (roomId: string, eventId: string) => void;
|
||||||
|
getMemberPowerTag: GetMemberPowerTag;
|
||||||
|
accessibleTagColors: Map<string, string>;
|
||||||
|
legacyUsernameColor: boolean;
|
||||||
|
hour24Clock: boolean;
|
||||||
|
dateFormatString: string;
|
||||||
|
};
|
||||||
|
function ThreadMessage({
|
||||||
|
room,
|
||||||
|
event,
|
||||||
|
renderContent,
|
||||||
|
onOpen,
|
||||||
|
getMemberPowerTag,
|
||||||
|
accessibleTagColors,
|
||||||
|
legacyUsernameColor,
|
||||||
|
hour24Clock,
|
||||||
|
dateFormatString,
|
||||||
|
}: ThreadMessageProps) {
|
||||||
|
const useAuthentication = useMediaAuthentication();
|
||||||
|
const mx = useMatrixClient();
|
||||||
|
|
||||||
|
const handleOpenClick: MouseEventHandler = (evt) => {
|
||||||
|
evt.stopPropagation();
|
||||||
|
const evtId = evt.currentTarget.getAttribute('data-event-id');
|
||||||
|
if (!evtId) return;
|
||||||
|
onOpen(room.roomId, evtId);
|
||||||
|
};
|
||||||
|
|
||||||
|
const renderOptions = () => (
|
||||||
|
<Box shrink="No" gap="200" alignItems="Center">
|
||||||
|
<Chip
|
||||||
|
data-event-id={event.getId()}
|
||||||
|
onClick={handleOpenClick}
|
||||||
|
variant="Secondary"
|
||||||
|
radii="Pill"
|
||||||
|
>
|
||||||
|
<Text size="T200">Open</Text>
|
||||||
|
</Chip>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
|
||||||
|
const sender = event.getSender()!;
|
||||||
|
const displayName = getMemberDisplayName(room, sender) ?? getMxIdLocalPart(sender) ?? sender;
|
||||||
|
const senderAvatarMxc = getMemberAvatarMxc(room, sender);
|
||||||
|
const getContent = (() => event.getContent()) as GetContentCallback;
|
||||||
|
|
||||||
|
const memberPowerTag = getMemberPowerTag(sender);
|
||||||
|
const tagColor = memberPowerTag?.color
|
||||||
|
? accessibleTagColors?.get(memberPowerTag.color)
|
||||||
|
: undefined;
|
||||||
|
const tagIconSrc = memberPowerTag?.icon
|
||||||
|
? getPowerTagIconSrc(mx, useAuthentication, memberPowerTag.icon)
|
||||||
|
: undefined;
|
||||||
|
|
||||||
|
const usernameColor = legacyUsernameColor ? colorMXID(sender) : tagColor;
|
||||||
|
|
||||||
|
const mEventId = event.getId();
|
||||||
|
|
||||||
|
if (!mEventId) return null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ModernLayout
|
||||||
|
before={
|
||||||
|
<AvatarBase>
|
||||||
|
<Avatar size="300">
|
||||||
|
<UserAvatar
|
||||||
|
userId={sender}
|
||||||
|
src={
|
||||||
|
senderAvatarMxc
|
||||||
|
? mxcUrlToHttp(mx, senderAvatarMxc, useAuthentication, 48, 48, 'crop') ??
|
||||||
|
undefined
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
|
alt={displayName}
|
||||||
|
renderFallback={() => <Icon size="200" src={Icons.User} filled />}
|
||||||
|
/>
|
||||||
|
</Avatar>
|
||||||
|
</AvatarBase>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<Box gap="300" justifyContent="SpaceBetween" alignItems="Center" grow="Yes">
|
||||||
|
<Box gap="200" alignItems="Baseline">
|
||||||
|
<Box alignItems="Center" gap="200">
|
||||||
|
<Username style={{ color: usernameColor }}>
|
||||||
|
<Text as="span" truncate>
|
||||||
|
<UsernameBold>{displayName}</UsernameBold>
|
||||||
|
</Text>
|
||||||
|
</Username>
|
||||||
|
{tagIconSrc && <PowerIcon size="100" iconSrc={tagIconSrc} />}
|
||||||
|
</Box>
|
||||||
|
<Time ts={event.getTs()} hour24Clock={hour24Clock} dateFormatString={dateFormatString} />
|
||||||
|
</Box>
|
||||||
|
{renderOptions()}
|
||||||
|
</Box>
|
||||||
|
{event.replyEventId && (
|
||||||
|
<Reply
|
||||||
|
room={room}
|
||||||
|
replyEventId={event.replyEventId}
|
||||||
|
threadRootId={event.threadRootId}
|
||||||
|
onClick={handleOpenClick}
|
||||||
|
getMemberPowerTag={getMemberPowerTag}
|
||||||
|
accessibleTagColors={accessibleTagColors}
|
||||||
|
legacyUsernameColor={legacyUsernameColor}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{renderContent(event.getType(), false, mEventId, event, displayName, getContent)}
|
||||||
|
</ModernLayout>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
type ThreadsTimelineProps = {
|
||||||
|
timelines: EventTimeline[];
|
||||||
|
requestClose: () => void;
|
||||||
|
};
|
||||||
|
export function ThreadsTimeline({ timelines, requestClose }: ThreadsTimelineProps) {
|
||||||
|
const mx = useMatrixClient();
|
||||||
|
const { navigateRoom } = useRoomNavigate();
|
||||||
|
const alive = useAlive();
|
||||||
|
const scrollRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
|
const room = useRoom();
|
||||||
|
const powerLevels = usePowerLevelsContext();
|
||||||
|
const creators = useRoomCreators(room);
|
||||||
|
|
||||||
|
const creatorsTag = useRoomCreatorsTag();
|
||||||
|
const powerLevelTags = usePowerLevelTags(room, powerLevels);
|
||||||
|
const getMemberPowerTag = useGetMemberPowerTag(room, creators, powerLevels);
|
||||||
|
|
||||||
|
const theme = useTheme();
|
||||||
|
const accessibleTagColors = useAccessiblePowerTagColors(theme.kind, creatorsTag, powerLevelTags);
|
||||||
|
|
||||||
|
const useAuthentication = useMediaAuthentication();
|
||||||
|
const [mediaAutoLoad] = useSetting(settingsAtom, 'mediaAutoLoad');
|
||||||
|
const [urlPreview] = useSetting(settingsAtom, 'urlPreview');
|
||||||
|
|
||||||
|
const direct = useIsDirectRoom();
|
||||||
|
const [legacyUsernameColor] = useSetting(settingsAtom, 'legacyUsernameColor');
|
||||||
|
|
||||||
|
const [hour24Clock] = useSetting(settingsAtom, 'hour24Clock');
|
||||||
|
const [dateFormatString] = useSetting(settingsAtom, 'dateFormatString');
|
||||||
|
|
||||||
|
const mentionClickHandler = useMentionClickHandler(room.roomId);
|
||||||
|
const spoilerClickHandler = useSpoilerClickHandler();
|
||||||
|
|
||||||
|
const linkifyOpts = useMemo<LinkifyOpts>(
|
||||||
|
() => ({
|
||||||
|
...LINKIFY_OPTS,
|
||||||
|
render: factoryRenderLinkifyWithMention((href) =>
|
||||||
|
renderMatrixMention(mx, room.roomId, href, makeMentionCustomProps(mentionClickHandler))
|
||||||
|
),
|
||||||
|
}),
|
||||||
|
[mx, room, mentionClickHandler]
|
||||||
|
);
|
||||||
|
const htmlReactParserOptions = useMemo<HTMLReactParserOptions>(
|
||||||
|
() =>
|
||||||
|
getReactCustomHtmlParser(mx, room.roomId, {
|
||||||
|
linkifyOpts,
|
||||||
|
useAuthentication,
|
||||||
|
handleSpoilerClick: spoilerClickHandler,
|
||||||
|
handleMentionClick: mentionClickHandler,
|
||||||
|
}),
|
||||||
|
[mx, room, linkifyOpts, mentionClickHandler, spoilerClickHandler, useAuthentication]
|
||||||
|
);
|
||||||
|
|
||||||
|
const renderMatrixEvent = useMatrixEventRenderer<
|
||||||
|
[string, MatrixEvent, string, GetContentCallback]
|
||||||
|
>(
|
||||||
|
{
|
||||||
|
[MessageEvent.RoomMessage]: (eventId, event, displayName, getContent) => {
|
||||||
|
if (event.isRedacted()) {
|
||||||
|
return <RedactedContent reason={event.getUnsigned().redacted_because?.content.reason} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
const threadDetail = getEventThreadDetail(event);
|
||||||
|
|
||||||
|
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
|
||||||
|
/>
|
||||||
|
{threadDetail && (
|
||||||
|
<ThreadSelectorContainer>
|
||||||
|
<ThreadSelector
|
||||||
|
room={room}
|
||||||
|
threadId={eventId}
|
||||||
|
threadDetail={threadDetail}
|
||||||
|
outlined
|
||||||
|
hour24Clock={hour24Clock}
|
||||||
|
dateFormatString={dateFormatString}
|
||||||
|
/>
|
||||||
|
</ThreadSelectorContainer>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
[MessageEvent.RoomMessageEncrypted]: (eventId, mEvent, displayName) => {
|
||||||
|
const evtTimeline = room.getTimelineForEvent(eventId);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<EncryptedContent mEvent={mEvent}>
|
||||||
|
{() => {
|
||||||
|
if (mEvent.isRedacted()) return <RedactedContent />;
|
||||||
|
if (mEvent.getType() === MessageEvent.Sticker)
|
||||||
|
return (
|
||||||
|
<MSticker
|
||||||
|
content={mEvent.getContent()}
|
||||||
|
renderImageContent={(props) => (
|
||||||
|
<ImageContent
|
||||||
|
{...props}
|
||||||
|
autoPlay={mediaAutoLoad}
|
||||||
|
renderImage={(p) => <Image {...p} loading="lazy" />}
|
||||||
|
renderViewer={(p) => <ImageViewer {...p} />}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
if (mEvent.getType() === MessageEvent.RoomMessage) {
|
||||||
|
const editedEvent =
|
||||||
|
evtTimeline && getEditedEvent(eventId, 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 || !!mEvent.replacingEvent()}
|
||||||
|
getContent={getContent}
|
||||||
|
mediaAutoLoad={mediaAutoLoad}
|
||||||
|
urlPreview={urlPreview}
|
||||||
|
htmlReactParserOptions={htmlReactParserOptions}
|
||||||
|
linkifyOpts={linkifyOpts}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (mEvent.getType() === MessageEvent.RoomMessageEncrypted)
|
||||||
|
return (
|
||||||
|
<Text>
|
||||||
|
<MessageNotDecryptedContent />
|
||||||
|
</Text>
|
||||||
|
);
|
||||||
|
return (
|
||||||
|
<Text>
|
||||||
|
<MessageUnsupportedContent />
|
||||||
|
</Text>
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
</EncryptedContent>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
[MessageEvent.Sticker]: (eventId, event, displayName, getContent) => {
|
||||||
|
if (event.isRedacted()) {
|
||||||
|
return <RedactedContent reason={event.getUnsigned().redacted_because?.content.reason} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
const threadDetail = getEventThreadDetail(event);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<MSticker
|
||||||
|
content={getContent()}
|
||||||
|
renderImageContent={(props) => (
|
||||||
|
<ImageContent
|
||||||
|
{...props}
|
||||||
|
autoPlay={mediaAutoLoad}
|
||||||
|
renderImage={(p) => <Image {...p} loading="lazy" />}
|
||||||
|
renderViewer={(p) => <ImageViewer {...p} />}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
{threadDetail && (
|
||||||
|
<ThreadSelectorContainer>
|
||||||
|
<ThreadSelector
|
||||||
|
room={room}
|
||||||
|
threadId={eventId}
|
||||||
|
threadDetail={threadDetail}
|
||||||
|
outlined
|
||||||
|
hour24Clock={hour24Clock}
|
||||||
|
dateFormatString={dateFormatString}
|
||||||
|
/>
|
||||||
|
</ThreadSelectorContainer>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
undefined,
|
||||||
|
(eventId, event) => {
|
||||||
|
if (event.isRedacted()) {
|
||||||
|
return <RedactedContent reason={event.getUnsigned().redacted_because?.content.reason} />;
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<Box grow="Yes" direction="Column">
|
||||||
|
<Text size="T400" priority="300">
|
||||||
|
<code className={customHtmlCss.Code}>{event.getType()}</code>
|
||||||
|
{' event'}
|
||||||
|
</Text>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
const handleOpen = (roomId: string, eventId: string) => {
|
||||||
|
navigateRoom(roomId, eventId);
|
||||||
|
requestClose();
|
||||||
|
};
|
||||||
|
|
||||||
|
const eventsLength = getTimelinesEventsCount(timelines);
|
||||||
|
const timelineToPaginate = timelines[timelines.length - 1];
|
||||||
|
const [paginationToken, setPaginationToken] = useState(
|
||||||
|
timelineToPaginate.getPaginationToken(Direction.Backward)
|
||||||
|
);
|
||||||
|
|
||||||
|
const virtualizer = useVirtualizer({
|
||||||
|
count: eventsLength,
|
||||||
|
getScrollElement: () => scrollRef.current,
|
||||||
|
estimateSize: () => 122,
|
||||||
|
overscan: 10,
|
||||||
|
});
|
||||||
|
const vItems = virtualizer.getVirtualItems();
|
||||||
|
|
||||||
|
const paginate = useCallback(async () => {
|
||||||
|
const moreToLoad = await mx.paginateEventTimeline(timelineToPaginate, {
|
||||||
|
backwards: true,
|
||||||
|
limit: 30,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (alive()) {
|
||||||
|
setPaginationToken(
|
||||||
|
moreToLoad ? timelineToPaginate.getPaginationToken(Direction.Backward) : null
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}, [mx, alive, timelineToPaginate]);
|
||||||
|
|
||||||
|
// auto paginate when scroll reach bottom
|
||||||
|
useEffect(() => {
|
||||||
|
const lastVItem = vItems.length > 0 ? vItems[vItems.length - 1] : undefined;
|
||||||
|
if (paginationToken && lastVItem && lastVItem.index === eventsLength - 1) {
|
||||||
|
paginate();
|
||||||
|
}
|
||||||
|
}, [vItems, paginationToken, eventsLength, paginate]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Scroll ref={scrollRef} size="300" hideTrack visibility="Hover">
|
||||||
|
<Box className={css.ThreadsMenuContent} direction="Column" gap="100">
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
position: 'relative',
|
||||||
|
height: virtualizer.getTotalSize(),
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{vItems.map((vItem) => {
|
||||||
|
const reverseTimelineIndex = eventsLength - vItem.index - 1;
|
||||||
|
|
||||||
|
const [timeline, baseIndex] = getTimelineAndBaseIndex(timelines, reverseTimelineIndex);
|
||||||
|
if (!timeline) return null;
|
||||||
|
const event = getTimelineEvent(
|
||||||
|
timeline,
|
||||||
|
getTimelineRelativeIndex(reverseTimelineIndex, baseIndex)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!event?.getId()) return null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<VirtualTile
|
||||||
|
virtualItem={vItem}
|
||||||
|
style={{ paddingBottom: config.space.S200 }}
|
||||||
|
ref={virtualizer.measureElement}
|
||||||
|
key={vItem.index}
|
||||||
|
>
|
||||||
|
<SequenceCard
|
||||||
|
key={event.getId()}
|
||||||
|
style={{ padding: config.space.S400, borderRadius: config.radii.R300 }}
|
||||||
|
variant="SurfaceVariant"
|
||||||
|
direction="Column"
|
||||||
|
>
|
||||||
|
<ThreadMessage
|
||||||
|
room={room}
|
||||||
|
event={event}
|
||||||
|
renderContent={renderMatrixEvent}
|
||||||
|
onOpen={handleOpen}
|
||||||
|
getMemberPowerTag={getMemberPowerTag}
|
||||||
|
accessibleTagColors={accessibleTagColors}
|
||||||
|
legacyUsernameColor={legacyUsernameColor || direct}
|
||||||
|
hour24Clock={hour24Clock}
|
||||||
|
dateFormatString={dateFormatString}
|
||||||
|
/>
|
||||||
|
</SequenceCard>
|
||||||
|
</VirtualTile>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
{paginationToken && <ThreadsLoading />}
|
||||||
|
</Box>
|
||||||
|
</Scroll>
|
||||||
|
);
|
||||||
|
}
|
||||||
1
src/app/features/room/threads-menu/index.ts
Normal file
1
src/app/features/room/threads-menu/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export * from './ThreadsMenu';
|
||||||
1
src/app/features/room/utils/index.ts
Normal file
1
src/app/features/room/utils/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export * from './timeline';
|
||||||
66
src/app/features/room/utils/timeline.ts
Normal file
66
src/app/features/room/utils/timeline.ts
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
import { Room, EventTimeline, Direction, MatrixEvent } from 'matrix-js-sdk';
|
||||||
|
|
||||||
|
export const getFirstLinkedTimeline = (
|
||||||
|
timeline: EventTimeline,
|
||||||
|
direction: Direction
|
||||||
|
): EventTimeline => {
|
||||||
|
const linkedTm = timeline.getNeighbouringTimeline(direction);
|
||||||
|
if (!linkedTm) return timeline;
|
||||||
|
return getFirstLinkedTimeline(linkedTm, direction);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getLinkedTimelines = (timeline: EventTimeline): EventTimeline[] => {
|
||||||
|
const firstTimeline = getFirstLinkedTimeline(timeline, Direction.Backward);
|
||||||
|
const timelines: EventTimeline[] = [];
|
||||||
|
|
||||||
|
for (
|
||||||
|
let nextTimeline: EventTimeline | null = firstTimeline;
|
||||||
|
nextTimeline;
|
||||||
|
nextTimeline = nextTimeline.getNeighbouringTimeline(Direction.Forward)
|
||||||
|
) {
|
||||||
|
timelines.push(nextTimeline);
|
||||||
|
}
|
||||||
|
return timelines;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const timelineToEventsCount = (t: EventTimeline) => t.getEvents().length;
|
||||||
|
export const getTimelinesEventsCount = (timelines: EventTimeline[]): number => {
|
||||||
|
const timelineEventCountReducer = (count: number, tm: EventTimeline) =>
|
||||||
|
count + timelineToEventsCount(tm);
|
||||||
|
return timelines.reduce(timelineEventCountReducer, 0);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getTimelineAndBaseIndex = (
|
||||||
|
timelines: EventTimeline[],
|
||||||
|
index: number
|
||||||
|
): [EventTimeline | undefined, number] => {
|
||||||
|
let uptoTimelineLen = 0;
|
||||||
|
const timeline = timelines.find((t) => {
|
||||||
|
uptoTimelineLen += t.getEvents().length;
|
||||||
|
if (index < uptoTimelineLen) return true;
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
if (!timeline) return [undefined, 0];
|
||||||
|
return [timeline, uptoTimelineLen - timeline.getEvents().length];
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getTimelineRelativeIndex = (absoluteIndex: number, timelineBaseIndex: number) =>
|
||||||
|
absoluteIndex - timelineBaseIndex;
|
||||||
|
|
||||||
|
export const getTimelineEvent = (timeline: EventTimeline, index: number): MatrixEvent | undefined =>
|
||||||
|
timeline.getEvents()[index];
|
||||||
|
|
||||||
|
export const getEventIdAbsoluteIndex = (
|
||||||
|
timelines: EventTimeline[],
|
||||||
|
eventTimeline: EventTimeline,
|
||||||
|
eventId: string
|
||||||
|
): number | undefined => {
|
||||||
|
const timelineIndex = timelines.findIndex((t) => t === eventTimeline);
|
||||||
|
if (timelineIndex === -1) return undefined;
|
||||||
|
const eventIndex = eventTimeline.getEvents().findIndex((evt) => evt.getId() === eventId);
|
||||||
|
if (eventIndex === -1) return undefined;
|
||||||
|
const baseIndex = timelines
|
||||||
|
.slice(0, timelineIndex)
|
||||||
|
.reduce((accValue, timeline) => timeline.getEvents().length + accValue, 0);
|
||||||
|
return baseIndex + eventIndex;
|
||||||
|
};
|
||||||
@@ -434,9 +434,8 @@ export function SearchModalRenderer() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// means some menu or modal window is open
|
const portalContainer = document.getElementById('portalContainer');
|
||||||
const lastNode = document.body.lastElementChild;
|
if (portalContainer && portalContainer.children.length > 0) {
|
||||||
if (lastNode && !lastNode.hasAttribute('data-last-node')) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setOpen(true);
|
setOpen(true);
|
||||||
|
|||||||
47
src/app/hooks/useComposingCheck.ts
Normal file
47
src/app/hooks/useComposingCheck.ts
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
import { useCallback, useEffect } from 'react';
|
||||||
|
import { useAtomValue, useSetAtom } from 'jotai';
|
||||||
|
import { lastCompositionEndAtom } from '../state/lastCompositionEnd';
|
||||||
|
|
||||||
|
interface TimeStamped {
|
||||||
|
readonly timeStamp: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useCompositionEndTracking(): void {
|
||||||
|
const setLastCompositionEnd = useSetAtom(lastCompositionEndAtom);
|
||||||
|
|
||||||
|
const recordCompositionEnd = useCallback(
|
||||||
|
(evt: TimeStamped) => {
|
||||||
|
setLastCompositionEnd(evt.timeStamp);
|
||||||
|
},
|
||||||
|
[setLastCompositionEnd]
|
||||||
|
);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
window.addEventListener('compositionend', recordCompositionEnd, { capture: true });
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener('compositionend', recordCompositionEnd, { capture: true });
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IsComposingLike {
|
||||||
|
readonly timeStamp: number;
|
||||||
|
readonly keyCode: number;
|
||||||
|
readonly nativeEvent: {
|
||||||
|
readonly isComposing?: boolean;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useComposingCheck({
|
||||||
|
compositionEndThreshold = 500,
|
||||||
|
}: { compositionEndThreshold?: number } = {}): (evt: IsComposingLike) => boolean {
|
||||||
|
const compositionEnd = useAtomValue(lastCompositionEndAtom);
|
||||||
|
return useCallback(
|
||||||
|
(evt: IsComposingLike): boolean =>
|
||||||
|
evt.nativeEvent.isComposing ||
|
||||||
|
(evt.keyCode === 229 &&
|
||||||
|
typeof compositionEnd !== 'undefined' &&
|
||||||
|
evt.timeStamp - compositionEnd < compositionEndThreshold),
|
||||||
|
[compositionEndThreshold, compositionEnd]
|
||||||
|
);
|
||||||
|
}
|
||||||
20
src/app/hooks/useRoomThreads.ts
Normal file
20
src/app/hooks/useRoomThreads.ts
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
import { useCallback } from 'react';
|
||||||
|
import { EventTimelineSet, Room } from 'matrix-js-sdk';
|
||||||
|
import { AsyncState, useAsyncCallbackValue } from './useAsyncCallback';
|
||||||
|
|
||||||
|
export const useRoomMyThreads = (room: Room): AsyncState<EventTimelineSet, Error> => {
|
||||||
|
const [threadsState] = useAsyncCallbackValue<EventTimelineSet, Error>(
|
||||||
|
useCallback(async () => {
|
||||||
|
await room.createThreadsTimelineSets();
|
||||||
|
await room.fetchRoomThreads();
|
||||||
|
|
||||||
|
const timelineSet = room.threadsTimelineSets[0];
|
||||||
|
if (timelineSet === undefined) {
|
||||||
|
throw new Error('Failed to fetch My Threads!');
|
||||||
|
}
|
||||||
|
return timelineSet;
|
||||||
|
}, [room])
|
||||||
|
);
|
||||||
|
|
||||||
|
return threadsState;
|
||||||
|
};
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import React, { useEffect } from 'react';
|
import React from 'react';
|
||||||
import { Provider as JotaiProvider } from 'jotai';
|
import { Provider as JotaiProvider } from 'jotai';
|
||||||
|
import { OverlayContainerProvider, PopOutContainerProvider, TooltipContainerProvider } from 'folds';
|
||||||
import { RouterProvider } from 'react-router-dom';
|
import { RouterProvider } from 'react-router-dom';
|
||||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
||||||
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
|
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
|
||||||
@@ -10,44 +11,44 @@ import { ConfigConfigError, ConfigConfigLoading } from './ConfigConfig';
|
|||||||
import { FeatureCheck } from './FeatureCheck';
|
import { FeatureCheck } from './FeatureCheck';
|
||||||
import { createRouter } from './Router';
|
import { createRouter } from './Router';
|
||||||
import { ScreenSizeProvider, useScreenSize } from '../hooks/useScreenSize';
|
import { ScreenSizeProvider, useScreenSize } from '../hooks/useScreenSize';
|
||||||
|
import { useCompositionEndTracking } from '../hooks/useComposingCheck';
|
||||||
|
|
||||||
const queryClient = new QueryClient();
|
const queryClient = new QueryClient();
|
||||||
|
|
||||||
const useLastNodeToDetectReactPortalEntry = () => {
|
|
||||||
useEffect(() => {
|
|
||||||
const lastDiv = document.createElement('div');
|
|
||||||
lastDiv.setAttribute('data-last-node', 'true');
|
|
||||||
document.body.appendChild(lastDiv);
|
|
||||||
}, []);
|
|
||||||
};
|
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const screenSize = useScreenSize();
|
const screenSize = useScreenSize();
|
||||||
|
useCompositionEndTracking();
|
||||||
|
|
||||||
useLastNodeToDetectReactPortalEntry();
|
const portalContainer = document.getElementById('portalContainer') ?? undefined;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ScreenSizeProvider value={screenSize}>
|
<TooltipContainerProvider value={portalContainer}>
|
||||||
<FeatureCheck>
|
<PopOutContainerProvider value={portalContainer}>
|
||||||
<ClientConfigLoader
|
<OverlayContainerProvider value={portalContainer}>
|
||||||
fallback={() => <ConfigConfigLoading />}
|
<ScreenSizeProvider value={screenSize}>
|
||||||
error={(err, retry, ignore) => (
|
<FeatureCheck>
|
||||||
<ConfigConfigError error={err} retry={retry} ignore={ignore} />
|
<ClientConfigLoader
|
||||||
)}
|
fallback={() => <ConfigConfigLoading />}
|
||||||
>
|
error={(err, retry, ignore) => (
|
||||||
{(clientConfig) => (
|
<ConfigConfigError error={err} retry={retry} ignore={ignore} />
|
||||||
<ClientConfigProvider value={clientConfig}>
|
)}
|
||||||
<QueryClientProvider client={queryClient}>
|
>
|
||||||
<JotaiProvider>
|
{(clientConfig) => (
|
||||||
<RouterProvider router={createRouter(clientConfig, screenSize)} />
|
<ClientConfigProvider value={clientConfig}>
|
||||||
</JotaiProvider>
|
<QueryClientProvider client={queryClient}>
|
||||||
<ReactQueryDevtools initialIsOpen={false} />
|
<JotaiProvider>
|
||||||
</QueryClientProvider>
|
<RouterProvider router={createRouter(clientConfig, screenSize)} />
|
||||||
</ClientConfigProvider>
|
</JotaiProvider>
|
||||||
)}
|
<ReactQueryDevtools initialIsOpen={false} />
|
||||||
</ClientConfigLoader>
|
</QueryClientProvider>
|
||||||
</FeatureCheck>
|
</ClientConfigProvider>
|
||||||
</ScreenSizeProvider>
|
)}
|
||||||
|
</ClientConfigLoader>
|
||||||
|
</FeatureCheck>
|
||||||
|
</ScreenSizeProvider>
|
||||||
|
</OverlayContainerProvider>
|
||||||
|
</PopOutContainerProvider>
|
||||||
|
</TooltipContainerProvider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import { makeNavToActivePathAtom } from '../../state/navToActivePath';
|
|||||||
import { NavToActivePathProvider } from '../../state/hooks/navToActivePath';
|
import { NavToActivePathProvider } from '../../state/hooks/navToActivePath';
|
||||||
import { makeOpenedSidebarFolderAtom } from '../../state/openedSidebarFolder';
|
import { makeOpenedSidebarFolderAtom } from '../../state/openedSidebarFolder';
|
||||||
import { OpenedSidebarFolderProvider } from '../../state/hooks/openedSidebarFolder';
|
import { OpenedSidebarFolderProvider } from '../../state/hooks/openedSidebarFolder';
|
||||||
|
import { makeRoomToActiveThreadAtom } from '../../state/roomToActiveThread';
|
||||||
|
import { RoomToActiveThreadProvider } from '../../state/hooks/roomToActiveThread';
|
||||||
|
|
||||||
type ClientInitStorageAtomProps = {
|
type ClientInitStorageAtomProps = {
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
@@ -22,15 +24,19 @@ export function ClientInitStorageAtom({ children }: ClientInitStorageAtomProps)
|
|||||||
|
|
||||||
const navToActivePathAtom = useMemo(() => makeNavToActivePathAtom(userId), [userId]);
|
const navToActivePathAtom = useMemo(() => makeNavToActivePathAtom(userId), [userId]);
|
||||||
|
|
||||||
|
const roomToActiveThreadAtom = useMemo(() => makeRoomToActiveThreadAtom(userId), [userId]);
|
||||||
|
|
||||||
const openedSidebarFolderAtom = useMemo(() => makeOpenedSidebarFolderAtom(userId), [userId]);
|
const openedSidebarFolderAtom = useMemo(() => makeOpenedSidebarFolderAtom(userId), [userId]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ClosedNavCategoriesProvider value={closedNavCategoriesAtom}>
|
<ClosedNavCategoriesProvider value={closedNavCategoriesAtom}>
|
||||||
<ClosedLobbyCategoriesProvider value={closedLobbyCategoriesAtom}>
|
<ClosedLobbyCategoriesProvider value={closedLobbyCategoriesAtom}>
|
||||||
<NavToActivePathProvider value={navToActivePathAtom}>
|
<NavToActivePathProvider value={navToActivePathAtom}>
|
||||||
<OpenedSidebarFolderProvider value={openedSidebarFolderAtom}>
|
<RoomToActiveThreadProvider value={roomToActiveThreadAtom}>
|
||||||
{children}
|
<OpenedSidebarFolderProvider value={openedSidebarFolderAtom}>
|
||||||
</OpenedSidebarFolderProvider>
|
{children}
|
||||||
|
</OpenedSidebarFolderProvider>
|
||||||
|
</RoomToActiveThreadProvider>
|
||||||
</NavToActivePathProvider>
|
</NavToActivePathProvider>
|
||||||
</ClosedLobbyCategoriesProvider>
|
</ClosedLobbyCategoriesProvider>
|
||||||
</ClosedNavCategoriesProvider>
|
</ClosedNavCategoriesProvider>
|
||||||
|
|||||||
55
src/app/state/hooks/roomToActiveThread.ts
Normal file
55
src/app/state/hooks/roomToActiveThread.ts
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
import { createContext, useCallback, useContext } from 'react';
|
||||||
|
import { useAtomValue, useSetAtom } from 'jotai';
|
||||||
|
import { RoomToActiveThreadAtom } from '../roomToActiveThread';
|
||||||
|
|
||||||
|
const RoomToActiveThreadAtomContext = createContext<RoomToActiveThreadAtom | null>(null);
|
||||||
|
export const RoomToActiveThreadProvider = RoomToActiveThreadAtomContext.Provider;
|
||||||
|
|
||||||
|
export const useRoomToActiveThreadAtom = (): RoomToActiveThreadAtom => {
|
||||||
|
const anAtom = useContext(RoomToActiveThreadAtomContext);
|
||||||
|
|
||||||
|
if (!anAtom) {
|
||||||
|
throw new Error('RoomToActiveThreadAtom is not provided!');
|
||||||
|
}
|
||||||
|
|
||||||
|
return anAtom;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const useThreadSelector = (roomId: string): ((threadId: string) => void) => {
|
||||||
|
const roomToActiveThreadAtom = useRoomToActiveThreadAtom();
|
||||||
|
const setRoomToActiveThread = useSetAtom(roomToActiveThreadAtom);
|
||||||
|
|
||||||
|
const onThreadSelect = useCallback(
|
||||||
|
(threadId: string) => {
|
||||||
|
setRoomToActiveThread({
|
||||||
|
type: 'PUT',
|
||||||
|
roomId,
|
||||||
|
threadId,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
[roomId, setRoomToActiveThread]
|
||||||
|
);
|
||||||
|
|
||||||
|
return onThreadSelect;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const useActiveThread = (roomId: string): string | undefined => {
|
||||||
|
const roomToActiveThreadAtom = useRoomToActiveThreadAtom();
|
||||||
|
const roomToActiveThread = useAtomValue(roomToActiveThreadAtom);
|
||||||
|
|
||||||
|
return roomToActiveThread.get(roomId);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const useThreadClose = (roomId: string): (() => void) => {
|
||||||
|
const roomToActiveThreadAtom = useRoomToActiveThreadAtom();
|
||||||
|
const setRoomToActiveThread = useSetAtom(roomToActiveThreadAtom);
|
||||||
|
|
||||||
|
const closeThread = useCallback(() => {
|
||||||
|
setRoomToActiveThread({
|
||||||
|
type: 'DELETE',
|
||||||
|
roomId,
|
||||||
|
});
|
||||||
|
}, [roomId, setRoomToActiveThread]);
|
||||||
|
|
||||||
|
return closeThread;
|
||||||
|
};
|
||||||
3
src/app/state/lastCompositionEnd.ts
Normal file
3
src/app/state/lastCompositionEnd.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
import { atom } from 'jotai';
|
||||||
|
|
||||||
|
export const lastCompositionEndAtom = atom<number | undefined>(undefined);
|
||||||
75
src/app/state/roomToActiveThread.ts
Normal file
75
src/app/state/roomToActiveThread.ts
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
import { atom, WritableAtom } from 'jotai';
|
||||||
|
import produce from 'immer';
|
||||||
|
import {
|
||||||
|
atomWithLocalStorage,
|
||||||
|
getLocalStorageItem,
|
||||||
|
setLocalStorageItem,
|
||||||
|
} from './utils/atomWithLocalStorage';
|
||||||
|
|
||||||
|
const ROOM_TO_ACTIVE_THREAD = 'roomToActiveThread';
|
||||||
|
|
||||||
|
const getStoreKey = (userId: string): string => `${ROOM_TO_ACTIVE_THREAD}${userId}`;
|
||||||
|
|
||||||
|
type RoomToActiveThread = Map<string, string>;
|
||||||
|
|
||||||
|
type RoomToActiveThreadAction =
|
||||||
|
| {
|
||||||
|
type: 'PUT';
|
||||||
|
roomId: string;
|
||||||
|
threadId: string;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
type: 'DELETE';
|
||||||
|
roomId: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type RoomToActiveThreadAtom = WritableAtom<
|
||||||
|
RoomToActiveThread,
|
||||||
|
[RoomToActiveThreadAction],
|
||||||
|
undefined
|
||||||
|
>;
|
||||||
|
|
||||||
|
export const makeRoomToActiveThreadAtom = (userId: string): RoomToActiveThreadAtom => {
|
||||||
|
const storeKey = getStoreKey(userId);
|
||||||
|
|
||||||
|
const baseRoomToActiveThread = atomWithLocalStorage<RoomToActiveThread>(
|
||||||
|
storeKey,
|
||||||
|
(key) => {
|
||||||
|
const obj: Record<string, string> = getLocalStorageItem(key, {});
|
||||||
|
return new Map(Object.entries(obj));
|
||||||
|
},
|
||||||
|
(key, value) => {
|
||||||
|
const obj: Record<string, string> = Object.fromEntries(value);
|
||||||
|
setLocalStorageItem(key, obj);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
const navToActivePathAtom = atom<RoomToActiveThread, [RoomToActiveThreadAction], undefined>(
|
||||||
|
(get) => get(baseRoomToActiveThread),
|
||||||
|
(get, set, action) => {
|
||||||
|
if (action.type === 'DELETE') {
|
||||||
|
set(
|
||||||
|
baseRoomToActiveThread,
|
||||||
|
produce(get(baseRoomToActiveThread), (draft) => {
|
||||||
|
draft.delete(action.roomId);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (action.type === 'PUT') {
|
||||||
|
set(
|
||||||
|
baseRoomToActiveThread,
|
||||||
|
produce(get(baseRoomToActiveThread), (draft) => {
|
||||||
|
draft.set(action.roomId, action.threadId);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return navToActivePathAtom;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const clearRoomToActiveThreadStore = (userId: string) => {
|
||||||
|
localStorage.removeItem(getStoreKey(userId));
|
||||||
|
};
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import { style } from '@vanilla-extract/css';
|
import { style } from '@vanilla-extract/css';
|
||||||
import { recipe } from '@vanilla-extract/recipes';
|
import { recipe } from '@vanilla-extract/recipes';
|
||||||
import { color, config, DefaultReset, toRem } from 'folds';
|
import { color, config, DefaultReset, toRem } from 'folds';
|
||||||
|
import { ContainerColor } from './ContainerColor.css';
|
||||||
|
|
||||||
export const MarginSpaced = style({
|
export const MarginSpaced = style({
|
||||||
marginBottom: config.space.S200,
|
marginBottom: config.space.S200,
|
||||||
@@ -92,11 +93,14 @@ export const CodeBlock = style([
|
|||||||
overflow: 'hidden',
|
overflow: 'hidden',
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
export const CodeBlockHeader = style({
|
export const CodeBlockHeader = style([
|
||||||
padding: `0 ${config.space.S200} 0 ${config.space.S300}`,
|
ContainerColor({ variant: 'Surface' }),
|
||||||
borderBottomWidth: config.borderWidth.B300,
|
{
|
||||||
gap: config.space.S200,
|
padding: `0 ${config.space.S200} 0 ${config.space.S300}`,
|
||||||
});
|
borderBottomWidth: config.borderWidth.B300,
|
||||||
|
gap: config.space.S200,
|
||||||
|
},
|
||||||
|
]);
|
||||||
export const CodeBlockInternal = style([
|
export const CodeBlockInternal = style([
|
||||||
CodeFont,
|
CodeFont,
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import {
|
|||||||
IPowerLevelsContent,
|
IPowerLevelsContent,
|
||||||
IPushRule,
|
IPushRule,
|
||||||
IPushRules,
|
IPushRules,
|
||||||
|
IThreadBundledRelationship,
|
||||||
JoinRule,
|
JoinRule,
|
||||||
MatrixClient,
|
MatrixClient,
|
||||||
MatrixEvent,
|
MatrixEvent,
|
||||||
@@ -16,6 +17,7 @@ import {
|
|||||||
RelationType,
|
RelationType,
|
||||||
Room,
|
Room,
|
||||||
RoomMember,
|
RoomMember,
|
||||||
|
THREAD_RELATION_TYPE,
|
||||||
} from 'matrix-js-sdk';
|
} from 'matrix-js-sdk';
|
||||||
import { CryptoBackend } from 'matrix-js-sdk/lib/common-crypto/CryptoBackend';
|
import { CryptoBackend } from 'matrix-js-sdk/lib/common-crypto/CryptoBackend';
|
||||||
import { AccountDataEvent } from '../../types/matrix/accountData';
|
import { AccountDataEvent } from '../../types/matrix/accountData';
|
||||||
@@ -201,6 +203,7 @@ export const isNotificationEvent = (mEvent: MatrixEvent) => {
|
|||||||
|
|
||||||
if (mEvent.isRedacted()) return false;
|
if (mEvent.isRedacted()) return false;
|
||||||
if (mEvent.getRelation()?.rel_type === 'm.replace') return false;
|
if (mEvent.getRelation()?.rel_type === 'm.replace') return false;
|
||||||
|
if (mEvent.getRelation()?.rel_type === 'm.thread') return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
@@ -551,3 +554,13 @@ export const guessPerfectParent = (
|
|||||||
|
|
||||||
return perfectParent;
|
return perfectParent;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getEventThreadDetail = (
|
||||||
|
mEvent: MatrixEvent
|
||||||
|
): IThreadBundledRelationship | undefined => {
|
||||||
|
const details = mEvent.getServerAggregatedRelation<IThreadBundledRelationship>(
|
||||||
|
THREAD_RELATION_TYPE.name
|
||||||
|
);
|
||||||
|
|
||||||
|
return details;
|
||||||
|
};
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { createClient, MatrixClient, IndexedDBStore, IndexedDBCryptoStore } from
|
|||||||
|
|
||||||
import { cryptoCallbacks } from './secretStorageKeys';
|
import { cryptoCallbacks } from './secretStorageKeys';
|
||||||
import { clearNavToActivePathStore } from '../app/state/navToActivePath';
|
import { clearNavToActivePathStore } from '../app/state/navToActivePath';
|
||||||
|
import { clearRoomToActiveThreadStore } from '../app/state/roomToActiveThread';
|
||||||
|
|
||||||
type Session = {
|
type Session = {
|
||||||
baseUrl: string;
|
baseUrl: string;
|
||||||
@@ -42,12 +43,14 @@ export const initClient = async (session: Session): Promise<MatrixClient> => {
|
|||||||
export const startClient = async (mx: MatrixClient) => {
|
export const startClient = async (mx: MatrixClient) => {
|
||||||
await mx.startClient({
|
await mx.startClient({
|
||||||
lazyLoadMembers: true,
|
lazyLoadMembers: true,
|
||||||
|
threadSupport: true,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const clearCacheAndReload = async (mx: MatrixClient) => {
|
export const clearCacheAndReload = async (mx: MatrixClient) => {
|
||||||
mx.stopClient();
|
mx.stopClient();
|
||||||
clearNavToActivePathStore(mx.getSafeUserId());
|
clearNavToActivePathStore(mx.getSafeUserId());
|
||||||
|
clearRoomToActiveThreadStore(mx.getSafeUserId());
|
||||||
await mx.store.deleteAllData();
|
await mx.store.deleteAllData();
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user