mirror of
https://github.com/SableClient/Sable.git
synced 2026-11-20 00:51:17 -08:00
merge up
This commit is contained in:
commit
eb608768cc
50 files changed
+1195
-337
No files matched your search
@@ -1,5 +0,0 @@
|
||||
---
|
||||
sable: minor
|
||||
---
|
||||
|
||||
Merge Voice Call updates from upstream.
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
sable: minor
|
||||
---
|
||||
|
||||
Allow for replying to state events.
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
sable: minor
|
||||
---
|
||||
|
||||
Add setting to enable picture-in-picture in element-call
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
---
|
||||
sable: minor
|
||||
---
|
||||
|
||||
Add support for audio and video in URL previews if homeserver provides it.
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
sable: patch
|
||||
---
|
||||
|
||||
change indexdb warning phrasing to include low disk space as possible reason
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
sable: patch
|
||||
---
|
||||
|
||||
Fix Element Call video/audio calls in DM and non-voice rooms: after joining through the lobby, the in-call grid now displays correctly instead of showing only the control bar.
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
sable: minor
|
||||
---
|
||||
|
||||
Added a new setting "Emoji Selector Character Threshold" to set the number of characters to type before the suggestions pop up.
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
sable: patch
|
||||
---
|
||||
|
||||
Disable autocorrect and spellcheck on the login page.
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
sable: minor
|
||||
---
|
||||
|
||||
Add keyboard navigation shortcuts for unread rooms (Alt+N, Alt+Shift+Up/Down), ARIA form label associations for screen reader accessibility, and a keyboard shortcuts settings page.
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
sable: patch
|
||||
---
|
||||
|
||||
Timeline message avatars now use the room-specific avatar and display name instead of the user's global profile, when set via `/myroomavatar` or `/myroomnick`.
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
sable: patch
|
||||
---
|
||||
|
||||
In-app notification banners now appear for DMs by default; desktop banner setting defaults to off; fixed space room navigation from banner tap.
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
sable: patch
|
||||
---
|
||||
|
||||
Executing /myroomnick or /myroomavatar without a new nickname/avatar now removes the nickname/avatar.
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
sable: patch
|
||||
---
|
||||
|
||||
Split typing and read status settings, allowing toggling off one and not the other.
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
sable: minor
|
||||
---
|
||||
|
||||
Added setting to always underline links.
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
sable: minor
|
||||
---
|
||||
|
||||
Added settings for disabling autoplay of gifs (& banners), stickers, and emojis.
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
sable: minor
|
||||
---
|
||||
|
||||
Added reduced motion setting. Let us know if any elements were missed!
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
sable: minor
|
||||
---
|
||||
|
||||
Replaced the monochrome mode with a saturation slider for more control.
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
sable: minor
|
||||
---
|
||||
|
||||
Added settings to Account that let you set if you are a cat or have cats, or not display other peoples cat status.
|
||||
@@ -1,5 +1,51 @@
|
||||
# Sable Client Changelog
|
||||
|
||||
## 1.5.2 (2026-03-08)
|
||||
|
||||
### Fixes
|
||||
|
||||
* Add `/hug`, `/cuddle`, `/wave`, `/headpat`, and `/poke` slash commands.
|
||||
* Swap Caddy port to 8080 + fixes for MDAD setups.
|
||||
* Adjust media sizing and URL preview layout
|
||||
* Fix picture in picture setting not effecting element-call
|
||||
* Fixed an issue where the app would fail to load after completing SSO login (e.g., logging in with matrix.org). Users are now correctly redirected to the app after SSO authentication completes.
|
||||
|
||||
## 1.5.1 (2026-03-08)
|
||||
|
||||
### Fixes
|
||||
|
||||
* Fix recent emojis ignoring letter threshold.
|
||||
* Disable in-app banners on desktop.
|
||||
|
||||
## 1.5.0 (2026-03-08)
|
||||
|
||||
### Features
|
||||
|
||||
* Merge Voice Call updates from upstream.
|
||||
* Allow for replying to state events.
|
||||
* Add message forwarding with metadata
|
||||
* Add setting to enable picture-in-picture in element-call
|
||||
* Add support for audio and video in URL previews if homeserver provides it.
|
||||
* Added a new setting "Emoji Selector Character Threshold" to set the number of characters to type before the suggestions pop up.
|
||||
* Add keyboard navigation shortcuts for unread rooms (Alt+N, Alt+Shift+Up/Down), ARIA form label associations for screen reader accessibility, and a keyboard shortcuts settings page.
|
||||
* Added setting to always underline links.
|
||||
* Added settings for disabling autoplay of gifs (& banners), stickers, and emojis.
|
||||
* Added reduced motion setting. Let us know if any elements were missed!
|
||||
* Replaced the monochrome mode with a saturation slider for more control.
|
||||
* Added settings to Account that let you set if you are a cat or have cats, or not display other peoples cat status.
|
||||
|
||||
### Fixes
|
||||
|
||||
* change indexdb warning phrasing to include low disk space as possible reason
|
||||
* Fix Element Call video/audio calls in DM and non-voice rooms: after joining through the lobby, the in-call grid now displays correctly instead of showing only the control bar.
|
||||
* Disable autocorrect and spellcheck on the login page.
|
||||
* Fix Tuwunel quotes often breaking timezones
|
||||
* Improved the UI of file descriptions
|
||||
* Timeline message avatars now use the room-specific avatar and display name instead of the user's global profile, when set via `/myroomavatar` or `/myroomnick`.
|
||||
* In-app notification banners now appear for DMs by default; desktop banner setting defaults to off; fixed space room navigation from banner tap.
|
||||
* Executing /myroomnick or /myroomavatar without a new nickname/avatar now removes the nickname/avatar.
|
||||
* Split typing and read status settings, allowing toggling off one and not the other.
|
||||
|
||||
## 1.4.0 (2026-03-06)
|
||||
|
||||
### Features
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
servers {
|
||||
protocols h1 h2c
|
||||
}
|
||||
}
|
||||
|
||||
:8080 {
|
||||
root * /app
|
||||
|
||||
# Enable on-the-fly compression for things not pre-compressed
|
||||
encode zstd gzip
|
||||
|
||||
file_server {
|
||||
precompressed br
|
||||
}
|
||||
|
||||
try_files {path} /index.html
|
||||
}
|
||||
+8
-5
@@ -19,10 +19,13 @@ FROM scratch AS site-dist
|
||||
COPY --from=builder /src/dist /
|
||||
|
||||
## App
|
||||
FROM nginx:1.29.5-alpine
|
||||
FROM caddy:2-alpine
|
||||
|
||||
# Strip the file capability set by the base image (cap_net_bind_service=+ep).
|
||||
# With --cap-drop=ALL the bounding set is empty, and the kernel refuses to exec
|
||||
# any binary that has file capabilities not present in the bounding set — even
|
||||
# if those capabilities aren't actually needed at runtime (we listen on :8080).
|
||||
RUN setcap -r /usr/bin/caddy
|
||||
|
||||
COPY --from=site-dist / /app
|
||||
COPY docker-nginx.conf /etc/nginx/conf.d/default.conf
|
||||
|
||||
RUN rm -rf /usr/share/nginx/html \
|
||||
&& ln -s /app /usr/share/nginx/html
|
||||
COPY Caddyfile /etc/caddy/Caddyfile
|
||||
@@ -1,21 +0,0 @@
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
|
||||
location / {
|
||||
root /usr/share/nginx/html;
|
||||
|
||||
rewrite ^/config.json$ /config.json break;
|
||||
rewrite ^/manifest.json$ /manifest.json break;
|
||||
|
||||
rewrite ^/sw.js$ /sw.js break;
|
||||
rewrite ^/pdf.worker.min.js$ /pdf.worker.min.js break;
|
||||
|
||||
rewrite ^/public/(.*)$ /public/$1 break;
|
||||
rewrite ^/assets/(.*)$ /assets/$1 break;
|
||||
|
||||
rewrite ^/element-call/dist/(.*)$ /element-call/dist/$1 break;
|
||||
|
||||
rewrite ^(.+)$ /index.html break;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -92,6 +92,6 @@
|
||||
</script>
|
||||
<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>
|
||||
</html>
|
||||
Generated
+37
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "sable",
|
||||
"version": "1.4.0",
|
||||
"version": "1.5.2",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "sable",
|
||||
"version": "1.4.0",
|
||||
"version": "1.5.2",
|
||||
"hasInstallScript": true,
|
||||
"license": "AGPL-3.0-only",
|
||||
"dependencies": {
|
||||
@@ -98,6 +98,7 @@
|
||||
"prettier": "3.8.1",
|
||||
"typescript": "^5.9.3",
|
||||
"vite": "^7.3.1",
|
||||
"vite-plugin-compression2": "2.5.0",
|
||||
"vite-plugin-pwa": "^1.2.0",
|
||||
"vite-plugin-static-copy": "^3.2.0",
|
||||
"vite-plugin-svgr": "4.5.0",
|
||||
@@ -14923,6 +14924,13 @@
|
||||
"url": "https://opencollective.com/webpack"
|
||||
}
|
||||
},
|
||||
"node_modules/tar-mini": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/tar-mini/-/tar-mini-0.2.0.tgz",
|
||||
"integrity": "sha512-+qfUHz700DWnRutdUsxRRVZ38G1Qr27OetwaMYTdg8hcPxf46U0S1Zf76dQMWRBmusOt2ZCK5kbIaiLkoGO7WQ==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/temp-dir": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/temp-dir/-/temp-dir-2.0.0.tgz",
|
||||
@@ -16035,6 +16043,17 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/vite-plugin-compression2": {
|
||||
"version": "2.5.0",
|
||||
"resolved": "https://registry.npmjs.org/vite-plugin-compression2/-/vite-plugin-compression2-2.5.0.tgz",
|
||||
"integrity": "sha512-bHxtBibPxxSn5eZSe0IAzvYucP/hg8Bz8ppjbH7lndU5kIHT+92qTkB4z9xWYfnyV0YHuir1SjOuyO0fzU4Vgg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@rollup/pluginutils": "^5.1.0",
|
||||
"tar-mini": "^0.2.0"
|
||||
}
|
||||
},
|
||||
"node_modules/vite-plugin-pwa": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/vite-plugin-pwa/-/vite-plugin-pwa-1.2.0.tgz",
|
||||
@@ -25820,6 +25839,12 @@
|
||||
"integrity": "sha512-g9ljZiwki/LfxmQADO3dEY1CbpmXT5Hm2fJ+QaGKwSXUylMybePR7/67YW7jOrrvjEgL1Fmz5kzyAjWVWLlucg==",
|
||||
"dev": true
|
||||
},
|
||||
"tar-mini": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/tar-mini/-/tar-mini-0.2.0.tgz",
|
||||
"integrity": "sha512-+qfUHz700DWnRutdUsxRRVZ38G1Qr27OetwaMYTdg8hcPxf46U0S1Zf76dQMWRBmusOt2ZCK5kbIaiLkoGO7WQ==",
|
||||
"dev": true
|
||||
},
|
||||
"temp-dir": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/temp-dir/-/temp-dir-2.0.0.tgz",
|
||||
@@ -26369,6 +26394,16 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"vite-plugin-compression2": {
|
||||
"version": "2.5.0",
|
||||
"resolved": "https://registry.npmjs.org/vite-plugin-compression2/-/vite-plugin-compression2-2.5.0.tgz",
|
||||
"integrity": "sha512-bHxtBibPxxSn5eZSe0IAzvYucP/hg8Bz8ppjbH7lndU5kIHT+92qTkB4z9xWYfnyV0YHuir1SjOuyO0fzU4Vgg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@rollup/pluginutils": "^5.1.0",
|
||||
"tar-mini": "^0.2.0"
|
||||
}
|
||||
},
|
||||
"vite-plugin-pwa": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/vite-plugin-pwa/-/vite-plugin-pwa-1.2.0.tgz",
|
||||
|
||||
+2
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "sable",
|
||||
"version": "1.4.0",
|
||||
"version": "1.5.2",
|
||||
"description": "Yet another matrix client fork",
|
||||
"type": "module",
|
||||
"packageManager": "[email protected]",
|
||||
@@ -114,6 +114,7 @@
|
||||
"prettier": "3.8.1",
|
||||
"typescript": "^5.9.3",
|
||||
"vite": "^7.3.1",
|
||||
"vite-plugin-compression2": "2.5.0",
|
||||
"vite-plugin-pwa": "^1.2.0",
|
||||
"vite-plugin-static-copy": "^3.2.0",
|
||||
"vite-plugin-svgr": "4.5.0",
|
||||
|
||||
@@ -2,10 +2,10 @@ import { memo, useMemo, useCallback } from 'react';
|
||||
import { MsgType } from '$types/matrix-sdk';
|
||||
import { testMatrixTo } from '$plugins/matrix-to';
|
||||
import { useSetting } from '$state/hooks/settings';
|
||||
import { settingsAtom } from '$state/settings';
|
||||
import { settingsAtom, CaptionPosition } from '$state/settings';
|
||||
import { HTMLReactParserOptions } from 'html-react-parser';
|
||||
import { Opts } from 'linkifyjs';
|
||||
import { config } from 'folds';
|
||||
import { Box, config } from 'folds';
|
||||
import {
|
||||
AudioContent,
|
||||
DownloadFile,
|
||||
@@ -33,6 +33,7 @@ import { ImageViewer } from './image-viewer';
|
||||
import { PdfViewer } from './Pdf-viewer';
|
||||
import { TextViewer } from './text-viewer';
|
||||
import { ClientSideHoverFreeze } from './ClientSideHoverFreeze';
|
||||
import { CuteEventType, MCuteEvent } from './message/MCuteEvent';
|
||||
|
||||
type RenderMessageContentProps = {
|
||||
displayName: string;
|
||||
@@ -74,6 +75,13 @@ function RenderMessageContentInternal({
|
||||
const content = useMemo(() => getContent<any>(), [getContent]);
|
||||
|
||||
const [autoplayGifs] = useSetting(settingsAtom, 'autoplayGifs');
|
||||
const [captionPosition] = useSetting(settingsAtom, 'captionPosition');
|
||||
const captionPositionMap = {
|
||||
[CaptionPosition.Above]: 'column-reverse',
|
||||
[CaptionPosition.Below]: 'column',
|
||||
[CaptionPosition.Inline]: 'row',
|
||||
[CaptionPosition.Hidden]: 'row',
|
||||
} satisfies Record<CaptionPosition, React.CSSProperties['flexDirection']>;
|
||||
|
||||
const renderBody = useCallback(
|
||||
(props: any) => (
|
||||
@@ -112,54 +120,89 @@ function RenderMessageContentInternal({
|
||||
);
|
||||
|
||||
const renderCaption = () => {
|
||||
if (captionPosition === CaptionPosition.Hidden) return null;
|
||||
if (content.filename && content.filename !== content.body) {
|
||||
if (captionPosition !== CaptionPosition.Inline)
|
||||
return (
|
||||
<MText
|
||||
style={CAPTION_STYLE}
|
||||
edited={edited}
|
||||
content={content}
|
||||
renderBody={renderBody}
|
||||
renderUrlsPreview={urlPreview ? renderUrlsPreview : undefined}
|
||||
/>
|
||||
);
|
||||
return (
|
||||
<MText
|
||||
style={CAPTION_STYLE}
|
||||
edited={edited}
|
||||
content={content}
|
||||
renderBody={renderBody}
|
||||
renderUrlsPreview={urlPreview ? renderUrlsPreview : undefined}
|
||||
/>
|
||||
<Box
|
||||
style={{
|
||||
padding: config.space.S200,
|
||||
wordBreak: 'break-word',
|
||||
maxWidth: '100%',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
justifyContent: 'center',
|
||||
flexShrink: 1,
|
||||
}}
|
||||
>
|
||||
<MText
|
||||
edited={edited}
|
||||
content={content}
|
||||
renderBody={renderBody}
|
||||
renderUrlsPreview={urlPreview ? renderUrlsPreview : undefined}
|
||||
/>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
const renderFile = () => (
|
||||
<>
|
||||
<MFile
|
||||
content={content}
|
||||
renderFileContent={({ body, mimeType, info, encInfo, url }) => (
|
||||
<FileContent
|
||||
body={body}
|
||||
mimeType={mimeType}
|
||||
renderAsPdfFile={() => (
|
||||
<ReadPdfFile
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
flexDirection: captionPositionMap[captionPosition],
|
||||
}}
|
||||
>
|
||||
<div>
|
||||
<MFile
|
||||
content={content}
|
||||
renderFileContent={({ body, mimeType, info, encInfo, url }) => (
|
||||
<FileContent
|
||||
body={body}
|
||||
mimeType={mimeType}
|
||||
renderAsPdfFile={() => (
|
||||
<ReadPdfFile
|
||||
body={body}
|
||||
mimeType={mimeType}
|
||||
url={url}
|
||||
encInfo={encInfo}
|
||||
renderViewer={(p) => <PdfViewer {...p} />}
|
||||
/>
|
||||
)}
|
||||
renderAsTextFile={() => (
|
||||
<ReadTextFile
|
||||
body={body}
|
||||
mimeType={mimeType}
|
||||
url={url}
|
||||
encInfo={encInfo}
|
||||
renderViewer={(p) => <TextViewer {...p} />}
|
||||
/>
|
||||
)}
|
||||
>
|
||||
<DownloadFile
|
||||
body={body}
|
||||
mimeType={mimeType}
|
||||
url={url}
|
||||
encInfo={encInfo}
|
||||
renderViewer={(p) => <PdfViewer {...p} />}
|
||||
info={info}
|
||||
/>
|
||||
)}
|
||||
renderAsTextFile={() => (
|
||||
<ReadTextFile
|
||||
body={body}
|
||||
mimeType={mimeType}
|
||||
url={url}
|
||||
encInfo={encInfo}
|
||||
renderViewer={(p) => <TextViewer {...p} />}
|
||||
/>
|
||||
)}
|
||||
>
|
||||
<DownloadFile body={body} mimeType={mimeType} url={url} encInfo={encInfo} info={info} />
|
||||
</FileContent>
|
||||
)}
|
||||
outlined={outlineAttachment}
|
||||
/>
|
||||
</FileContent>
|
||||
)}
|
||||
outlined={outlineAttachment}
|
||||
/>
|
||||
</div>
|
||||
{renderCaption()}
|
||||
</>
|
||||
</div>
|
||||
);
|
||||
|
||||
if (msgType === MsgType.Text) {
|
||||
@@ -205,79 +248,100 @@ function RenderMessageContentInternal({
|
||||
(typeof content.url === 'string' && content.url.toLowerCase().includes('gif'));
|
||||
|
||||
return (
|
||||
<>
|
||||
<MImage
|
||||
content={content}
|
||||
renderImageContent={(imageProps) => (
|
||||
<ImageContent
|
||||
{...imageProps}
|
||||
autoPlay={mediaAutoLoad}
|
||||
renderImage={(p) => {
|
||||
if (isGif && !autoplayGifs && p.src) {
|
||||
return (
|
||||
<ClientSideHoverFreeze src={p.src}>
|
||||
<Image {...p} loading="lazy" />
|
||||
</ClientSideHoverFreeze>
|
||||
);
|
||||
}
|
||||
return <Image {...p} loading="lazy" />;
|
||||
}}
|
||||
renderViewer={(p) => <ImageViewer {...p} />}
|
||||
/>
|
||||
)}
|
||||
outlined={outlineAttachment}
|
||||
/>
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
flexDirection: captionPositionMap[captionPosition],
|
||||
}}
|
||||
>
|
||||
<div>
|
||||
<MImage
|
||||
content={content}
|
||||
renderImageContent={(imageProps) => (
|
||||
<ImageContent
|
||||
{...imageProps}
|
||||
autoPlay={mediaAutoLoad}
|
||||
renderImage={(p) => {
|
||||
if (isGif && !autoplayGifs && p.src) {
|
||||
return (
|
||||
<ClientSideHoverFreeze src={p.src}>
|
||||
<Image {...p} loading="lazy" />
|
||||
</ClientSideHoverFreeze>
|
||||
);
|
||||
}
|
||||
return <Image {...p} loading="lazy" />;
|
||||
}}
|
||||
renderViewer={(p) => <ImageViewer {...p} />}
|
||||
/>
|
||||
)}
|
||||
outlined={outlineAttachment}
|
||||
/>
|
||||
</div>
|
||||
{renderCaption()}
|
||||
</>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (msgType === MsgType.Video) {
|
||||
return (
|
||||
<>
|
||||
<MVideo
|
||||
content={content}
|
||||
renderAsFile={renderFile}
|
||||
renderVideoContent={({ body, info, ...videoProps }) => (
|
||||
<VideoContent
|
||||
body={body}
|
||||
info={info}
|
||||
{...videoProps}
|
||||
renderThumbnail={
|
||||
mediaAutoLoad
|
||||
? () => (
|
||||
<ThumbnailContent
|
||||
info={info}
|
||||
renderImage={(src) => (
|
||||
<Image alt={body} title={body} src={src} loading="lazy" />
|
||||
)}
|
||||
/>
|
||||
)
|
||||
: undefined
|
||||
}
|
||||
renderVideo={(p) => <Video {...p} />}
|
||||
/>
|
||||
)}
|
||||
outlined={outlineAttachment}
|
||||
/>
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
flexDirection: captionPositionMap[captionPosition],
|
||||
}}
|
||||
>
|
||||
<div>
|
||||
<MVideo
|
||||
content={content}
|
||||
renderAsFile={renderFile}
|
||||
renderVideoContent={({ body, info, ...videoProps }) => (
|
||||
<VideoContent
|
||||
body={body}
|
||||
info={info}
|
||||
{...videoProps}
|
||||
renderThumbnail={
|
||||
mediaAutoLoad
|
||||
? () => (
|
||||
<ThumbnailContent
|
||||
info={info}
|
||||
renderImage={(src) => (
|
||||
<Image alt={body} title={body} src={src} loading="lazy" />
|
||||
)}
|
||||
/>
|
||||
)
|
||||
: undefined
|
||||
}
|
||||
renderVideo={(p) => <Video {...p} />}
|
||||
/>
|
||||
)}
|
||||
outlined={outlineAttachment}
|
||||
/>
|
||||
</div>
|
||||
{renderCaption()}
|
||||
</>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (msgType === MsgType.Audio) {
|
||||
return (
|
||||
<>
|
||||
<MAudio
|
||||
content={content}
|
||||
renderAsFile={renderFile}
|
||||
renderAudioContent={(audioProps) => (
|
||||
<AudioContent {...audioProps} renderMediaControl={(p) => <MediaControl {...p} />} />
|
||||
)}
|
||||
outlined={outlineAttachment}
|
||||
/>
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
flexDirection: captionPositionMap[captionPosition],
|
||||
}}
|
||||
>
|
||||
<div>
|
||||
<MAudio
|
||||
content={content}
|
||||
renderAsFile={renderFile}
|
||||
renderAudioContent={(audioProps) => (
|
||||
<AudioContent {...audioProps} renderMediaControl={(p) => <MediaControl {...p} />} />
|
||||
)}
|
||||
outlined={outlineAttachment}
|
||||
/>
|
||||
</div>
|
||||
{renderCaption()}
|
||||
</>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -285,6 +349,23 @@ function RenderMessageContentInternal({
|
||||
if (msgType === MsgType.Location) return <MLocation content={content} />;
|
||||
if (msgType === 'm.bad.encrypted') return <MBadEncrypted />;
|
||||
|
||||
// cute events
|
||||
if (msgType === 'im.fluffychat.cute_event')
|
||||
return (
|
||||
<MCuteEvent
|
||||
content={content}
|
||||
type={content?.cute_type}
|
||||
mentionedUserIds={content?.['m.mentions']?.user_ids}
|
||||
/>
|
||||
);
|
||||
if (msgType === 'fyi.cisnt.headpat')
|
||||
return (
|
||||
<MCuteEvent
|
||||
content={content}
|
||||
type={CuteEventType.Headpat}
|
||||
mentionedUserIds={content?.['m.mentions']?.user_ids}
|
||||
/>
|
||||
);
|
||||
return <UnsupportedContent />;
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,12 @@ export function EmoticonAutocomplete({
|
||||
getEmoticonSearchStr,
|
||||
SEARCH_OPTIONS
|
||||
);
|
||||
const autoCompleteEmoticon = result ? result.items.slice(0, 20) : recentEmoji;
|
||||
const autoCompleteEmoticon = useMemo(() => {
|
||||
if (query.text.length < emojiThreshold) {
|
||||
return [];
|
||||
}
|
||||
return result ? result.items.slice(0, 20) : recentEmoji;
|
||||
}, [query.text.length, emojiThreshold, result, recentEmoji]);
|
||||
|
||||
useEffect(() => {
|
||||
if (query.text && query.text.length >= emojiThreshold) {
|
||||
|
||||
@@ -4,7 +4,7 @@ import { DefaultReset } from 'folds';
|
||||
export const Image = style([
|
||||
DefaultReset,
|
||||
{
|
||||
objectFit: 'cover',
|
||||
objectFit: 'contain',
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
},
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
// rendering for cute events (e.g. hug, cuddle, etc.)
|
||||
|
||||
import { MessageTextBody } from './layout';
|
||||
|
||||
export enum CuteEventType {
|
||||
Hug = 'hug',
|
||||
Cuddle = 'cuddle',
|
||||
Wave = 'wave',
|
||||
Poke = 'poke',
|
||||
Headpat = 'headpat',
|
||||
// currently unused, but could be added in the future if there's demand for it
|
||||
Kiss = 'kiss',
|
||||
}
|
||||
|
||||
type MCuteEventProps = {
|
||||
// Content is only used to check if the event is valid, the actual text is generated based on the type and mentioned users
|
||||
content: string | undefined;
|
||||
// The type of cute event (e.g. hug, cuddle, etc.)
|
||||
type: CuteEventType;
|
||||
// The user IDs mentioned in the event (e.g. the target of the hug/cuddle/etc.)
|
||||
mentionedUserIds?: string[];
|
||||
};
|
||||
|
||||
export function MCuteEvent({ content, type, mentionedUserIds }: MCuteEventProps) {
|
||||
if (!content) return null;
|
||||
|
||||
let cuteText = '';
|
||||
switch (type) {
|
||||
case CuteEventType.Hug:
|
||||
cuteText = `hugs ${mentionedUserIds?.[0] || 'you'}`;
|
||||
break;
|
||||
case CuteEventType.Cuddle:
|
||||
cuteText = `cuddles ${mentionedUserIds?.[0] || 'you'}`;
|
||||
break;
|
||||
case CuteEventType.Kiss:
|
||||
// in here for future expansion
|
||||
// would need some kind of filtering to prevent abuse (e.g. someone sending a kiss event to a random user to harass them)
|
||||
// cuteText = `kisses ${mentionedUserIds?.[0] || 'you'}`;
|
||||
cuteText =
|
||||
'currently disabled kiss event, in light of potential abuse, may be added in the future with proper filtering';
|
||||
break;
|
||||
case CuteEventType.Wave:
|
||||
cuteText = `waves at ${mentionedUserIds?.[0] || 'you'}`;
|
||||
break;
|
||||
case CuteEventType.Poke:
|
||||
cuteText = `pokes ${mentionedUserIds?.[0] || 'you'}`;
|
||||
break;
|
||||
case CuteEventType.Headpat:
|
||||
cuteText = `gives headpats to ${mentionedUserIds?.[0] || 'you'}`;
|
||||
break;
|
||||
default:
|
||||
cuteText = `sends ${mentionedUserIds?.[0] || 'you'} a cute event`;
|
||||
}
|
||||
|
||||
return (
|
||||
<MessageTextBody notice>
|
||||
<em data-cute-event data-cute-type={type}>
|
||||
{cuteText}
|
||||
</em>
|
||||
</MessageTextBody>
|
||||
);
|
||||
}
|
||||
@@ -31,6 +31,7 @@ import {
|
||||
MessageUnsupportedContent,
|
||||
} from './content';
|
||||
import { MessageTextBody } from './layout';
|
||||
import { unwrapForwardedContent } from './modals/MessageForward';
|
||||
|
||||
export function MBadEncrypted() {
|
||||
return (
|
||||
@@ -86,6 +87,10 @@ export function MText({ edited, content, renderBody, renderUrlsPreview, style }:
|
||||
typeof content.formatted_body === 'string' ? content.formatted_body : undefined;
|
||||
|
||||
const trimmedBody = useMemo(() => trimReplyFromBody(body), [body]);
|
||||
const unwrappedForwardedContent = useMemo(
|
||||
() => unwrapForwardedContent(customBody ?? body),
|
||||
[customBody, body]
|
||||
);
|
||||
|
||||
const safeCustomBody = useMemo(() => {
|
||||
if (!customBody) return undefined;
|
||||
@@ -96,6 +101,10 @@ export function MText({ edited, content, renderBody, renderUrlsPreview, style }:
|
||||
return customBody;
|
||||
}, [customBody]);
|
||||
|
||||
const isForwarded = useMemo(() => {
|
||||
const forwardMeta = content['moe.sable.message.forward'];
|
||||
return typeof forwardMeta === 'object';
|
||||
}, [content]);
|
||||
const isJumbo = useMemo(() => {
|
||||
if (!trimmedBody || trimmedBody.length >= 500) return false;
|
||||
if (!JUMBO_EMOJI_REG.test(trimmedBody)) return false;
|
||||
@@ -113,6 +122,19 @@ export function MText({ edited, content, renderBody, renderUrlsPreview, style }:
|
||||
const urlsMatch = renderUrlsPreview && trimmedBody.match(URL_REG);
|
||||
const urls = urlsMatch ? [...new Set(urlsMatch)] : undefined;
|
||||
|
||||
if (isForwarded && unwrappedForwardedContent) {
|
||||
return (
|
||||
<MessageTextBody preWrap={typeof unwrappedForwardedContent !== 'string'} style={style}>
|
||||
{renderBody({
|
||||
body: trimmedBody,
|
||||
customBody: unwrappedForwardedContent,
|
||||
})}
|
||||
{edited && <MessageEditedContent />}
|
||||
{renderUrlsPreview && urls && urls.length > 0 && renderUrlsPreview(urls)}
|
||||
</MessageTextBody>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<MessageTextBody
|
||||
@@ -228,17 +250,30 @@ export function MImage({ content, renderImageContent, outlined }: MImageProps) {
|
||||
if (typeof mxcUrl !== 'string') {
|
||||
return <BrokenContent />;
|
||||
}
|
||||
const height = scaleYDimension(imgInfo?.w || 400, 400, imgInfo?.h || 400);
|
||||
const MAX_SIZE = 400;
|
||||
const imgW = imgInfo?.w ?? MAX_SIZE;
|
||||
const imgH = imgInfo?.h ?? MAX_SIZE;
|
||||
const aspectRatio = imgInfo?.w && imgInfo?.h ? `${imgW} / ${imgH}` : undefined;
|
||||
// this garbage is for portrait images, we cap the width so the card doesn't exceed the bounds of the image
|
||||
const displayWidth = imgH > imgW ? Math.round(MAX_SIZE * (imgW / imgH)) : MAX_SIZE;
|
||||
|
||||
return (
|
||||
<Attachment outlined={outlined}>
|
||||
<Attachment
|
||||
style={{
|
||||
flexGrow: 1,
|
||||
flexShrink: 0,
|
||||
width: toRem(displayWidth),
|
||||
}}
|
||||
outlined={outlined}
|
||||
>
|
||||
<AttachmentBox
|
||||
style={{
|
||||
height: toRem(height < 48 ? 48 : height),
|
||||
aspectRatio,
|
||||
maxHeight: toRem(MAX_SIZE),
|
||||
}}
|
||||
>
|
||||
{renderImageContent({
|
||||
body: content.body || 'Image',
|
||||
body: content.filename || 'Image',
|
||||
info: imgInfo,
|
||||
mimeType: imgInfo?.mimetype,
|
||||
url: mxcUrl,
|
||||
@@ -278,12 +313,18 @@ export function MVideo({ content, renderAsFile, renderVideoContent, outlined }:
|
||||
return <BrokenContent />;
|
||||
}
|
||||
|
||||
const height = scaleYDimension(videoInfo.w || 400, 400, videoInfo.h || 400);
|
||||
const height = Math.min(scaleYDimension(videoInfo.w || 400, 400, videoInfo.h || 400), 400);
|
||||
|
||||
const filename = content.filename ?? content.body ?? 'Video';
|
||||
|
||||
return (
|
||||
<Attachment outlined={outlined}>
|
||||
<Attachment
|
||||
style={{
|
||||
flexGrow: 1,
|
||||
flexShrink: 0,
|
||||
}}
|
||||
outlined={outlined}
|
||||
>
|
||||
<AttachmentHeader>
|
||||
<FileHeader
|
||||
body={filename}
|
||||
|
||||
@@ -23,7 +23,7 @@ export const Attachment = recipe({
|
||||
export type AttachmentVariants = RecipeVariants<typeof Attachment>;
|
||||
|
||||
export const AttachmentHeader = style({
|
||||
padding: config.space.S300,
|
||||
padding: config.space.S100,
|
||||
});
|
||||
|
||||
export const AttachmentBox = style([
|
||||
|
||||
@@ -6,6 +6,7 @@ import { modalAtom, ModalType } from '$state/modal';
|
||||
import { MessageReportInternal } from './MessageReport';
|
||||
import { MessageDeleteInternal } from './MessageDelete';
|
||||
import { MessageSourceInternal } from './MessageSource';
|
||||
import { MessageForwardInternal } from './MessageForward';
|
||||
import { MessageAllReactionInternal } from './MessageReactions';
|
||||
import { MessageReadReceiptInternal } from './MessageReadRecipts';
|
||||
|
||||
@@ -40,6 +41,12 @@ export function GlobalModalManager() {
|
||||
</Box>
|
||||
)}
|
||||
|
||||
{modal.type === ModalType.Forward && (
|
||||
<Box>
|
||||
<MessageForwardInternal room={modal.room} mEvent={modal.mEvent} onClose={close} />
|
||||
</Box>
|
||||
)}
|
||||
|
||||
{modal.type === ModalType.Source && (
|
||||
<Modal variant="Surface" size="300">
|
||||
<MessageSourceInternal room={modal.room} mEvent={modal.mEvent} onClose={close} />
|
||||
|
||||
@@ -0,0 +1,285 @@
|
||||
// Modal for message forwarding, which allows users to select a room to forward the message to
|
||||
|
||||
import { useMatrixClient } from '$hooks/useMatrixClient';
|
||||
import { modalAtom, ModalType } from '$state/modal';
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
Dialog,
|
||||
Header,
|
||||
Icon,
|
||||
Icons,
|
||||
IconButton,
|
||||
MenuItem,
|
||||
Text,
|
||||
config,
|
||||
Scroll,
|
||||
as,
|
||||
} from 'folds';
|
||||
import { useAtomValue, useSetAtom } from 'jotai';
|
||||
import { JoinRule, MatrixEvent, Room } from '$types/matrix-sdk';
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
import { allRoomsAtom } from '$state/room-list/roomList';
|
||||
import { useAllJoinedRoomsSet, useGetRoom } from '$hooks/useGetRoom';
|
||||
import { factoryRoomIdByActivity } from '$utils/sort';
|
||||
import * as css from '$features/room/message/styles.css';
|
||||
import { sanitizeCustomHtml } from '$utils/sanitize';
|
||||
import { getStateEvents } from '$utils/room';
|
||||
import { StateEvent } from '$types/matrix/room';
|
||||
|
||||
// Message forwarding component
|
||||
export const MessageForwardItem = as<'button', MessageForwardItemProps>(
|
||||
({ room, mEvent, onClose, ...props }: MessageForwardItemProps) => {
|
||||
const setModal = useSetAtom(modalAtom);
|
||||
|
||||
const handleClick = () => {
|
||||
setModal({
|
||||
type: ModalType.Forward,
|
||||
room,
|
||||
mEvent,
|
||||
});
|
||||
onClose?.();
|
||||
};
|
||||
|
||||
return (
|
||||
<MenuItem
|
||||
size="300"
|
||||
after={<Icon size="100" src={Icons.ArrowRight} />}
|
||||
radii="300"
|
||||
{...props}
|
||||
onClick={handleClick}
|
||||
>
|
||||
<Text className={css.MessageMenuItemText} as="span" size="T300" truncate>
|
||||
Forward
|
||||
</Text>
|
||||
</MenuItem>
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
export const unwrapForwardedContent = (content: string) => {
|
||||
// unwrap the content of a forwarded message if it was wrapped in a blockquote with the data-forward-marker attribute
|
||||
const parser = new DOMParser();
|
||||
const doc = parser.parseFromString(content, 'text/html');
|
||||
const forwardMarker = doc.querySelector('[data-forward-marker]');
|
||||
if (forwardMarker) {
|
||||
const blockquote = forwardMarker.querySelector('blockquote');
|
||||
if (blockquote) {
|
||||
return blockquote.innerHTML;
|
||||
}
|
||||
}
|
||||
return content;
|
||||
};
|
||||
|
||||
type MessageForwardInternalProps = {
|
||||
room: Room;
|
||||
mEvent: MatrixEvent;
|
||||
onClose: () => void;
|
||||
};
|
||||
|
||||
type ForwardMeta = {
|
||||
v: 1;
|
||||
is_forwarded: true;
|
||||
original_timestamp: number;
|
||||
original_room_id?: string;
|
||||
original_event_id?: string;
|
||||
// to mark that event_id and room_id are not present
|
||||
original_event_private: boolean;
|
||||
};
|
||||
|
||||
export function MessageForwardInternal({ room, mEvent, onClose }: MessageForwardInternalProps) {
|
||||
const mx = useMatrixClient();
|
||||
|
||||
const [isTargetSelected, setIsTargetSelected] = useState(false);
|
||||
const [isForwardSuccess, setIsForwardSuccess] = useState(false);
|
||||
const [isForwardError, setIsForwardError] = useState(false);
|
||||
const [targetRoomId, setTargetRoomId] = useState<string | null>(null);
|
||||
|
||||
// detect if it's a public room or not
|
||||
const joinRule = room.getJoinRule() ?? JoinRule.Invite;
|
||||
|
||||
const parentSpaceIds = getStateEvents(room, StateEvent.SpaceParent)
|
||||
.map((e) => e.getStateKey())
|
||||
.filter((id): id is string => Boolean(id));
|
||||
|
||||
const isInPublicSpace = parentSpaceIds.some((spaceId) => {
|
||||
const space = mx.getRoom(spaceId);
|
||||
return Boolean(space?.isSpaceRoom()) && space?.getJoinRule() === JoinRule.Public;
|
||||
});
|
||||
|
||||
// A room is private if its join rule is Invite (or other non-public/non-knock/non-restricted),
|
||||
// or it's Restricted but NOT inside a public space.
|
||||
const isPrivate =
|
||||
joinRule === JoinRule.Invite ||
|
||||
(joinRule === JoinRule.Restricted && !isInPublicSpace) ||
|
||||
(joinRule !== JoinRule.Public &&
|
||||
joinRule !== JoinRule.Knock &&
|
||||
joinRule !== JoinRule.Restricted);
|
||||
|
||||
const allRooms = useAtomValue(allRoomsAtom);
|
||||
const allJoinedRooms = useAllJoinedRoomsSet();
|
||||
const getRoom = useGetRoom(allJoinedRooms);
|
||||
// possible targets to forward the message to
|
||||
const forwardTargets = useMemo(
|
||||
() =>
|
||||
allRooms
|
||||
.filter((id) => id !== room.roomId)
|
||||
.filter((id) => {
|
||||
const target = getRoom(id);
|
||||
return !!target && !target.isSpaceRoom() && target.maySendMessage();
|
||||
})
|
||||
.sort(factoryRoomIdByActivity(mx)),
|
||||
[allRooms, room.roomId, getRoom, mx]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (isForwardSuccess) {
|
||||
setTimeout(() => {
|
||||
// close the modal if the message was forwarded successfully
|
||||
onClose();
|
||||
}, 2000);
|
||||
}
|
||||
}, [isForwardSuccess, onClose]);
|
||||
|
||||
// actually forward the message to the selected room
|
||||
const handleForwardClick = () => {
|
||||
if (!targetRoomId) return;
|
||||
|
||||
const targetRoom = getRoom(targetRoomId);
|
||||
const eventId = mEvent.getId();
|
||||
if (!targetRoom || !eventId) return;
|
||||
|
||||
type SendEventType = Parameters<typeof mx.sendEvent>[2];
|
||||
type SendEventContent = Parameters<typeof mx.sendEvent>[3];
|
||||
|
||||
const eventType = mEvent.getType() as SendEventType;
|
||||
// using reference relation to indicate that this is a forwarded message,
|
||||
// which allows clients to display it as such
|
||||
|
||||
const bodyModifText = `(Forwarded message from ${isPrivate ? 'a private room' : (getRoom(room.roomId)?.name ?? 'a room')})`;
|
||||
let newBodyPlain = '';
|
||||
let newBodyHtml = '';
|
||||
// transform if msgtype is m.text
|
||||
if (mEvent.getContent().msgtype === 'm.text') {
|
||||
const original = mEvent.getContent().body;
|
||||
newBodyPlain = `${bodyModifText}\n\n${original
|
||||
.split('\n')
|
||||
.map((l: string) => `> ${l}`)
|
||||
.join('\n')}`;
|
||||
const safeHtml = sanitizeCustomHtml(original).replace(/\n/g, '<br>');
|
||||
newBodyHtml =
|
||||
`<div class="forwarded" data-forward-marker>` +
|
||||
`<p>${sanitizeCustomHtml(bodyModifText)}</p>` +
|
||||
`<blockquote>${safeHtml}</blockquote>` +
|
||||
`</div>`;
|
||||
}
|
||||
let content;
|
||||
// handle privacy stuff
|
||||
if (isPrivate) {
|
||||
// if the message is from a private room, we should strip any media or mentions to avoid leaking information to the target room
|
||||
// we can still include the original message content in the body of the message, so we'll just use a fallback text/plain content with the original message body
|
||||
content = {
|
||||
...mEvent.getContent(),
|
||||
body: newBodyPlain,
|
||||
format: 'org.matrix.custom.html',
|
||||
formatted_body: newBodyHtml,
|
||||
'moe.sable.message.forward': {
|
||||
v: 1,
|
||||
is_forwarded: true,
|
||||
original_timestamp: mEvent.getTs(),
|
||||
original_event_private: true,
|
||||
} satisfies ForwardMeta,
|
||||
};
|
||||
} else {
|
||||
content = {
|
||||
...mEvent.getContent(),
|
||||
body: newBodyPlain,
|
||||
format: 'org.matrix.custom.html',
|
||||
formatted_body: newBodyHtml,
|
||||
'm.relates_to': {
|
||||
rel_type: 'm.reference',
|
||||
event_id: eventId,
|
||||
},
|
||||
'moe.sable.message.forward': {
|
||||
v: 1,
|
||||
is_forwarded: true,
|
||||
original_timestamp: mEvent.getTs(),
|
||||
original_room_id: room.roomId,
|
||||
original_event_id: eventId,
|
||||
original_event_private: false,
|
||||
} satisfies ForwardMeta,
|
||||
};
|
||||
}
|
||||
|
||||
try {
|
||||
mx.sendEvent(targetRoom.roomId, null, eventType, content as unknown as SendEventContent).then(
|
||||
() => setIsForwardSuccess(true)
|
||||
);
|
||||
} catch {
|
||||
setIsForwardSuccess(false);
|
||||
setIsForwardError(true);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog variant="Surface">
|
||||
<Header
|
||||
style={{
|
||||
padding: `0 ${config.space.S200} 0 ${config.space.S400}`,
|
||||
borderBottomWidth: config.borderWidth.B300,
|
||||
}}
|
||||
variant="Surface"
|
||||
size="500"
|
||||
>
|
||||
<Box grow="Yes">
|
||||
<Text size="H4">Forward Message</Text>
|
||||
</Box>
|
||||
<IconButton size="300" onClick={onClose} radii="300">
|
||||
<Icon src={Icons.Cross} />
|
||||
</IconButton>
|
||||
</Header>
|
||||
<Box direction="Column" style={{ height: '300px' }}>
|
||||
<Scroll hideTrack>
|
||||
<Box direction="Column" style={{ padding: config.space.S300 }}>
|
||||
{forwardTargets.map((roomId) => {
|
||||
const target = getRoom(roomId);
|
||||
if (!target) return null;
|
||||
return (
|
||||
<MenuItem
|
||||
key={roomId}
|
||||
data-room-id={roomId}
|
||||
onClick={() => {
|
||||
setIsTargetSelected(true);
|
||||
setTargetRoomId(roomId);
|
||||
}}
|
||||
variant={targetRoomId === roomId ? 'Success' : 'Surface'}
|
||||
aria-pressed={targetRoomId === roomId}
|
||||
size="400"
|
||||
radii="400"
|
||||
>
|
||||
<Text truncate>{target.name}</Text>
|
||||
</MenuItem>
|
||||
);
|
||||
})}
|
||||
</Box>
|
||||
</Scroll>
|
||||
{isTargetSelected && targetRoomId && (
|
||||
<Button style={{ margin: config.space.S300 }} onClick={handleForwardClick}>
|
||||
<Text>Forward to {getRoom(targetRoomId)?.name}</Text>
|
||||
</Button>
|
||||
)}
|
||||
{isForwardError && (
|
||||
<Text size="T300" color="Critical600" style={{ margin: config.space.S300 }}>
|
||||
Failed to forward message. Please try again.
|
||||
</Text>
|
||||
)}
|
||||
</Box>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
||||
type MessageForwardItemProps = {
|
||||
room: Room;
|
||||
mEvent: MatrixEvent;
|
||||
onClose?: () => void;
|
||||
};
|
||||
@@ -1,5 +1,24 @@
|
||||
import { ReactNode, useEffect, useState } from 'react';
|
||||
import { Box, Chip, Icon, IconButton, Icons, Text, Tooltip, color, config, toRem } from 'folds';
|
||||
import { ReactNode, useEffect, useMemo, useState } from 'react';
|
||||
import {
|
||||
Box,
|
||||
Chip,
|
||||
Icon,
|
||||
IconButton,
|
||||
Icons,
|
||||
Scroll,
|
||||
Text,
|
||||
Tooltip,
|
||||
TooltipProvider,
|
||||
color,
|
||||
config,
|
||||
toRem,
|
||||
} from 'folds';
|
||||
import { HTMLReactParserOptions } from 'html-react-parser';
|
||||
import { useMediaAuthentication } from '$hooks/useMediaAuthentication';
|
||||
import { Opts as LinkifyOpts } from 'linkifyjs';
|
||||
import { getReactCustomHtmlParser, LINKIFY_OPTS } from '$plugins/react-custom-html-parser';
|
||||
import { useSpoilerClickHandler } from '$hooks/useSpoilerClickHandler';
|
||||
import { RenderBody } from '$components/message';
|
||||
import { UploadStatus, UploadSuccess, useBindUploadAtom } from '$state/upload';
|
||||
import { useMatrixClient } from '$hooks/useMatrixClient';
|
||||
import { TUploadContent } from '$utils/matrix';
|
||||
@@ -102,6 +121,7 @@ type UploadCardRendererProps = {
|
||||
setDesc: (fileItem: TUploadItem, body: string, formatted_body: string) => void;
|
||||
onRemove: (file: TUploadContent) => void;
|
||||
onComplete?: (upload: UploadSuccess) => void;
|
||||
roomId: string;
|
||||
};
|
||||
export function UploadCardRenderer({
|
||||
isEncrypted,
|
||||
@@ -110,6 +130,7 @@ export function UploadCardRenderer({
|
||||
setDesc,
|
||||
onRemove,
|
||||
onComplete,
|
||||
roomId,
|
||||
}: UploadCardRendererProps) {
|
||||
const mx = useMatrixClient();
|
||||
const mediaConfig = useMediaConfig();
|
||||
@@ -141,6 +162,20 @@ export function UploadCardRenderer({
|
||||
onComplete?.(upload);
|
||||
}
|
||||
}, [upload, onComplete]);
|
||||
|
||||
const linkifyOpts = useMemo<LinkifyOpts>(() => ({ ...LINKIFY_OPTS }), []);
|
||||
|
||||
const spoilerClickHandler = useSpoilerClickHandler();
|
||||
const useAuthentication = useMediaAuthentication();
|
||||
const htmlReactParserOptions = useMemo<HTMLReactParserOptions>(
|
||||
() =>
|
||||
getReactCustomHtmlParser(mx, roomId, {
|
||||
linkifyOpts,
|
||||
useAuthentication,
|
||||
handleSpoilerClick: spoilerClickHandler,
|
||||
}),
|
||||
[linkifyOpts, mx, roomId, spoilerClickHandler, useAuthentication]
|
||||
);
|
||||
return (
|
||||
<UploadCard
|
||||
radii="300"
|
||||
@@ -159,17 +194,35 @@ export function UploadCardRenderer({
|
||||
<Text size="B300">Retry</Text>
|
||||
</Chip>
|
||||
)}
|
||||
<IconButton
|
||||
onClick={() => {
|
||||
setIsDescribed(!isDescribed);
|
||||
}}
|
||||
aria-label="Add Upload Description"
|
||||
variant="SurfaceVariant"
|
||||
radii="Pill"
|
||||
size="300"
|
||||
>
|
||||
<Icon src={isDescribed ? Icons.ChevronBottom : Icons.ChevronTop} size="50" />
|
||||
</IconButton>
|
||||
{!isDescribed && (
|
||||
<IconButton
|
||||
onClick={() => {
|
||||
setIsDescribed(true);
|
||||
}}
|
||||
aria-label="Add Upload Description"
|
||||
variant="SurfaceVariant"
|
||||
radii="Pill"
|
||||
size="300"
|
||||
>
|
||||
<Icon src={Icons.Pencil} size="50" />
|
||||
</IconButton>
|
||||
)}
|
||||
{isDescribed && (
|
||||
<TooltipProvider
|
||||
delay={400}
|
||||
position="Top"
|
||||
style={{ textAlign: 'center' }}
|
||||
tooltip={
|
||||
<Tooltip>
|
||||
<Text size="H5">
|
||||
Don't forget to save your description before sending the message!
|
||||
</Text>
|
||||
</Tooltip>
|
||||
}
|
||||
>
|
||||
{(triggerRef) => <Icon ref={triggerRef} src={Icons.Info} size="50" />}
|
||||
</TooltipProvider>
|
||||
)}
|
||||
|
||||
<IconButton
|
||||
onClick={removeUpload}
|
||||
@@ -214,6 +267,7 @@ export function UploadCardRenderer({
|
||||
</Text>
|
||||
</UploadCardError>
|
||||
)}
|
||||
|
||||
{isDescribed && (
|
||||
<DescriptionEditor
|
||||
value={fileItem.formatted_body || fileItem.body}
|
||||
@@ -221,25 +275,34 @@ export function UploadCardRenderer({
|
||||
setDesc(fileItem, plainText, htmlContent);
|
||||
setIsDescribed(false);
|
||||
}}
|
||||
onCancel={() => setIsDescribed(false)}
|
||||
/>
|
||||
)}
|
||||
{!isDescribed && fileItem.body && fileItem.body.length > 0 && (
|
||||
<Tooltip
|
||||
<Scroll
|
||||
direction="Vertical"
|
||||
variant="SurfaceVariant"
|
||||
visibility="Always"
|
||||
size="300"
|
||||
style={{
|
||||
maxHeight: toRem(105),
|
||||
overflow: 'scroll',
|
||||
backgroundColor: 'var(--sable-bg-container)',
|
||||
borderRadius: config.radii.R400,
|
||||
maxHeight: '180px',
|
||||
marginTop: config.space.S0,
|
||||
overflowY: 'auto',
|
||||
}}
|
||||
>
|
||||
<Text
|
||||
size="T200"
|
||||
style={{
|
||||
height: '100%',
|
||||
wordBreak: 'break-word',
|
||||
}}
|
||||
>
|
||||
{fileItem.body}
|
||||
</Text>
|
||||
</Tooltip>
|
||||
<Box style={{ padding: config.space.S200, wordBreak: 'break-word' }}>
|
||||
<Text size="T200" priority="400" as="div">
|
||||
<RenderBody
|
||||
body={fileItem.body}
|
||||
customBody={fileItem.formatted_body}
|
||||
htmlReactParserOptions={htmlReactParserOptions}
|
||||
linkifyOpts={linkifyOpts}
|
||||
/>
|
||||
</Text>
|
||||
</Box>
|
||||
</Scroll>
|
||||
)}
|
||||
</>
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ type DescriptionEditorProps = {
|
||||
isSaving?: boolean;
|
||||
imagePackRooms?: any[];
|
||||
onSave: (plaintext: string, htmlContent: string) => void;
|
||||
onCancel: () => void;
|
||||
};
|
||||
|
||||
export function DescriptionEditor({
|
||||
@@ -51,6 +52,7 @@ export function DescriptionEditor({
|
||||
isSaving,
|
||||
imagePackRooms,
|
||||
onSave,
|
||||
onCancel,
|
||||
}: DescriptionEditorProps) {
|
||||
const editor = useEditor();
|
||||
const [enterForNewline] = useSetting(settingsAtom, 'enterForNewline');
|
||||
@@ -129,6 +131,7 @@ export function DescriptionEditor({
|
||||
(evt) => {
|
||||
if (isKeyHotkey('escape', evt)) {
|
||||
evt.preventDefault();
|
||||
onCancel();
|
||||
return;
|
||||
}
|
||||
const prevWordRange = getPrevWorldRange(editor);
|
||||
@@ -137,7 +140,7 @@ export function DescriptionEditor({
|
||||
: undefined;
|
||||
setAutocompleteQuery(query);
|
||||
},
|
||||
[editor]
|
||||
[editor, onCancel]
|
||||
);
|
||||
|
||||
const handleCloseAutocomplete = useCallback(() => {
|
||||
@@ -180,18 +183,33 @@ export function DescriptionEditor({
|
||||
justifyContent="SpaceBetween"
|
||||
gap="100"
|
||||
>
|
||||
<Box gap="200" alignItems="Center">
|
||||
<Chip
|
||||
onClick={handleSave}
|
||||
variant="Primary"
|
||||
radii="Pill"
|
||||
outlined
|
||||
before={
|
||||
isSaving ? <Spinner variant="Primary" fill="Soft" size="100" /> : undefined
|
||||
}
|
||||
>
|
||||
<Text size="B300">{isSaving ? 'Saving' : 'Save'}</Text>
|
||||
</Chip>
|
||||
<Box gap="200">
|
||||
<Box gap="200" alignItems="Center">
|
||||
<Chip
|
||||
onClick={handleSave}
|
||||
variant="Primary"
|
||||
radii="Pill"
|
||||
outlined
|
||||
before={
|
||||
isSaving ? <Spinner variant="Primary" fill="Soft" size="100" /> : undefined
|
||||
}
|
||||
>
|
||||
<Text size="B300">{isSaving ? 'Saving' : 'Save'}</Text>
|
||||
</Chip>
|
||||
</Box>
|
||||
<Box gap="200" alignItems="Center">
|
||||
<Chip
|
||||
onClick={onCancel}
|
||||
variant="Warning"
|
||||
radii="Pill"
|
||||
outlined
|
||||
before={
|
||||
isSaving ? <Spinner variant="Primary" fill="Soft" size="100" /> : undefined
|
||||
}
|
||||
>
|
||||
<Text size="B300">Cancel</Text>
|
||||
</Chip>
|
||||
</Box>
|
||||
</Box>
|
||||
<Box gap="Inherit">
|
||||
<IconButton
|
||||
|
||||
@@ -5,7 +5,6 @@ export const UrlPreview = style([
|
||||
DefaultReset,
|
||||
{
|
||||
width: toRem(400),
|
||||
minHeight: toRem(102),
|
||||
backgroundColor: color.SurfaceVariant.Container,
|
||||
color: color.SurfaceVariant.OnContainer,
|
||||
border: `${config.borderWidth.B300} solid ${color.SurfaceVariant.ContainerLine}`,
|
||||
|
||||
@@ -54,69 +54,14 @@ export const UrlPreviewCard = as<'div', { url: string; ts: number; mediaType?: s
|
||||
return (
|
||||
<Box
|
||||
grow="Yes"
|
||||
direction={prev['og:video'] ? 'ColumnReverse' : 'Row'}
|
||||
direction="Column"
|
||||
style={{
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
overflow: 'hidden',
|
||||
width: '100%',
|
||||
}}
|
||||
>
|
||||
{(prev['og:video'] && (
|
||||
<VideoContent
|
||||
style={{
|
||||
aspectRatio:
|
||||
((prev['og:video:width'] as number) ?? 1) /
|
||||
((prev['og:video:height'] as number) ?? 1),
|
||||
}}
|
||||
body={prev['og:title']}
|
||||
info={{}}
|
||||
url={prev['og:video'] as string}
|
||||
mimeType={(prev['og:video:type'] as string) ?? ''}
|
||||
renderVideo={(vidProps) => <Video style={{ objectFit: 'contain' }} {...vidProps} />}
|
||||
renderThumbnail={() => <Image src={imgUrl ?? undefined} />}
|
||||
/>
|
||||
)) ||
|
||||
(prev['og:image'] && (
|
||||
<Box style={{ flexShrink: 0, height: '100px' }}>
|
||||
{' '}
|
||||
<ImageContent
|
||||
style={{
|
||||
height: '100%',
|
||||
aspectRatio: (prev['og:image:width'] ?? 1) / (prev['og:image:height'] ?? 1),
|
||||
position: 'relative',
|
||||
width: 'auto',
|
||||
}}
|
||||
autoPlay
|
||||
body={prev['og:title']}
|
||||
url={prev['og:image']}
|
||||
renderViewer={(p) => <ImageViewer {...p} />}
|
||||
renderImage={(p) => (
|
||||
<Image
|
||||
{...p}
|
||||
style={{
|
||||
height: '100%',
|
||||
width: 'auto',
|
||||
objectFit: 'contain',
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</Box>
|
||||
)) ||
|
||||
(prev['og:audio'] && (
|
||||
<Box className={css.UrlPreviewAudio} style={{ flexShrink: 0 }}>
|
||||
<AudioContent
|
||||
url={(prev['og:audio'] as string) ?? ''}
|
||||
mimeType={(prev['og:audio:type'] as string) ?? ''}
|
||||
info={{}}
|
||||
renderMediaControl={(p) => <MediaControl {...p} />}
|
||||
/>
|
||||
</Box>
|
||||
))}
|
||||
<UrlPreviewContent
|
||||
style={{
|
||||
flex: 1,
|
||||
minWidth: 0,
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
@@ -147,6 +92,70 @@ export const UrlPreviewCard = as<'div', { url: string; ts: number; mediaType?: s
|
||||
</Text>
|
||||
)}
|
||||
</UrlPreviewContent>
|
||||
{prev['og:video'] && (
|
||||
<VideoContent
|
||||
style={{
|
||||
width: '100%',
|
||||
aspectRatio:
|
||||
((prev['og:video:width'] as number) ?? 1) /
|
||||
((prev['og:video:height'] as number) ?? 1),
|
||||
}}
|
||||
body={prev['og:title']}
|
||||
info={{}}
|
||||
url={prev['og:video'] as string}
|
||||
mimeType={(prev['og:video:type'] as string) ?? ''}
|
||||
renderVideo={(vidProps) => <Video style={{ objectFit: 'contain' }} {...vidProps} />}
|
||||
renderThumbnail={() => <Image src={imgUrl ?? undefined} />}
|
||||
/>
|
||||
)}
|
||||
{!prev['og:video'] &&
|
||||
prev['og:image'] &&
|
||||
(() => {
|
||||
const ogW = prev['og:image:width'];
|
||||
const ogH = prev['og:image:height'];
|
||||
const aspectRatio = ogW && ogH ? `${ogW} / ${ogH}` : undefined;
|
||||
return (
|
||||
<Box
|
||||
style={{
|
||||
width: '100%',
|
||||
maxHeight: '400px',
|
||||
aspectRatio: aspectRatio ?? '16 / 9',
|
||||
flexShrink: 0,
|
||||
overflow: 'hidden',
|
||||
position: 'relative',
|
||||
}}
|
||||
>
|
||||
<ImageContent
|
||||
style={{ width: '100%', height: '100%', position: 'absolute', inset: 0 }}
|
||||
autoPlay
|
||||
body={prev['og:title']}
|
||||
url={prev['og:image']}
|
||||
renderViewer={(p) => <ImageViewer {...p} />}
|
||||
renderImage={(p) => (
|
||||
<Image
|
||||
{...p}
|
||||
style={{
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
objectFit: 'contain',
|
||||
objectPosition: 'center',
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</Box>
|
||||
);
|
||||
})()}
|
||||
{!prev['og:video'] && !prev['og:image'] && prev['og:audio'] && (
|
||||
<Box className={css.UrlPreviewAudio} style={{ flexShrink: 0 }}>
|
||||
<AudioContent
|
||||
url={(prev['og:audio'] as string) ?? ''}
|
||||
mimeType={(prev['og:audio:type'] as string) ?? ''}
|
||||
info={{}}
|
||||
renderMediaControl={(p) => <MediaControl {...p} />}
|
||||
/>
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
@@ -197,9 +206,7 @@ export const UrlPreviewCard = as<'div', { url: string; ts: number; mediaType?: s
|
||||
maxWidth: '100%',
|
||||
margin: 0,
|
||||
}
|
||||
: {
|
||||
width: '600px',
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
>
|
||||
{previewContent}
|
||||
|
||||
@@ -108,7 +108,7 @@ function UserExtendedSection({
|
||||
return new Intl.DateTimeFormat([], {
|
||||
hour: 'numeric',
|
||||
minute: '2-digit',
|
||||
timeZone: profile.timezone,
|
||||
timeZone: profile.timezone.replace(/^["']|["']$/g, ''),
|
||||
}).format(new Date());
|
||||
} catch {
|
||||
return null;
|
||||
@@ -159,11 +159,11 @@ function UserExtendedSection({
|
||||
</Text>
|
||||
</Box>
|
||||
)}
|
||||
{localTime && (
|
||||
{localTime && profile.timezone && (
|
||||
<Box alignItems="Center" gap="100">
|
||||
<Icon size="50" src={Icons.Clock} style={{ opacity: 0.5 }} />
|
||||
<Text size="T200" priority="400">
|
||||
{localTime} ({profile.timezone})
|
||||
{localTime} ({profile.timezone.replace(/^["']|["']$/g, '')})
|
||||
</Text>
|
||||
</Box>
|
||||
)}
|
||||
|
||||
@@ -717,6 +717,7 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
|
||||
setMetadata={handleFileMetadata}
|
||||
onRemove={handleRemoveUpload}
|
||||
setDesc={setDesc}
|
||||
roomId={roomId}
|
||||
/>
|
||||
))}
|
||||
</UploadBoardContent>
|
||||
|
||||
@@ -132,7 +132,7 @@ import { useGetMemberPowerTag } from '$hooks/useMemberPowerTag';
|
||||
import { profilesCacheAtom } from '$state/userRoomProfile';
|
||||
import { ClientSideHoverFreeze } from '$components/ClientSideHoverFreeze';
|
||||
import * as css from './RoomTimeline.css';
|
||||
import { EncryptedContent, Event, Message, Reactions } from './message';
|
||||
import { EncryptedContent, Event, ForwardedMessageProps, Message, Reactions } from './message';
|
||||
|
||||
const TimelineFloat = as<'div', css.TimelineFloatVariants>(
|
||||
({ position, className, ...props }, ref) => (
|
||||
@@ -1338,6 +1338,29 @@ export function RoomTimeline({
|
||||
const senderDisplayName =
|
||||
getMemberDisplayName(room, senderId, nicknames) ?? getMxIdLocalPart(senderId) ?? senderId;
|
||||
|
||||
// determine if message is forwarded by checking for the presence of the 'moe.sable.message.forward' key in the event content
|
||||
const forwardContent = safeContent['moe.sable.message.forward'] as
|
||||
| {
|
||||
original_timestamp?: unknown;
|
||||
original_room_id?: string;
|
||||
original_event_id?: string;
|
||||
original_event_private?: boolean;
|
||||
}
|
||||
| undefined;
|
||||
|
||||
const messageForwardedProps: ForwardedMessageProps | undefined = forwardContent
|
||||
? {
|
||||
isForwarded: true,
|
||||
originalTimestamp:
|
||||
typeof forwardContent.original_timestamp === 'number'
|
||||
? forwardContent.original_timestamp
|
||||
: mEvent.getTs(),
|
||||
originalRoomId: forwardContent.original_room_id ?? room.roomId,
|
||||
originalEventId: forwardContent.original_event_id ?? '',
|
||||
originalEventPrivate: forwardContent.original_event_private ?? false,
|
||||
}
|
||||
: undefined;
|
||||
|
||||
return (
|
||||
<Message
|
||||
key={mEvent.getId()}
|
||||
@@ -1361,6 +1384,7 @@ export function RoomTimeline({
|
||||
onReactionToggle={handleReactionToggle}
|
||||
senderId={senderId}
|
||||
senderDisplayName={senderDisplayName}
|
||||
messageForwardedProps={messageForwardedProps}
|
||||
sendStatus={mEvent.getAssociatedStatus()}
|
||||
onResend={handleResend}
|
||||
onDeleteFailedSend={handleDeleteFailedSend}
|
||||
|
||||
@@ -75,9 +75,11 @@ import { useBlobCache } from '$hooks/useBlobCache';
|
||||
import { MessageAllReactionItem } from '$components/message/modals/MessageReactions';
|
||||
import { MessageReadReceiptItem } from '$components/message/modals/MessageReadRecipts';
|
||||
import { MessageSourceCodeItem } from '$components/message/modals/MessageSource';
|
||||
import { MessageForwardItem } from '$components/message/modals/MessageForward';
|
||||
import { MessageDeleteItem } from '$components/message/modals/MessageDelete';
|
||||
import { MessageReportItem } from '$components/message/modals/MessageReport';
|
||||
import { filterPronounsByLanguage } from '$utils/pronouns';
|
||||
import { useMentionClickHandler } from '$hooks/useMentionClickHandler';
|
||||
import { MessageEditor } from './MessageEditor';
|
||||
import * as css from './styles.css';
|
||||
|
||||
@@ -155,6 +157,7 @@ export const MessageCopyLinkItem = as<
|
||||
);
|
||||
});
|
||||
|
||||
// message pinning
|
||||
export const MessagePinItem = as<
|
||||
'button',
|
||||
{
|
||||
@@ -195,6 +198,14 @@ export const MessagePinItem = as<
|
||||
);
|
||||
});
|
||||
|
||||
export type ForwardedMessageProps = {
|
||||
originalTimestamp: number;
|
||||
isForwarded: boolean;
|
||||
originalRoomId: string;
|
||||
originalEventId: string;
|
||||
originalEventPrivate: boolean;
|
||||
};
|
||||
|
||||
export type MessageProps = {
|
||||
room: Room;
|
||||
mEvent: MatrixEvent;
|
||||
@@ -230,6 +241,7 @@ export type MessageProps = {
|
||||
sendStatus?: EventStatus | null;
|
||||
onResend?: (event: MatrixEvent) => void;
|
||||
onDeleteFailedSend?: (event: MatrixEvent) => void;
|
||||
messageForwardedProps?: ForwardedMessageProps;
|
||||
};
|
||||
|
||||
function useMobileDoubleTap(callback: () => void, delay = 300) {
|
||||
@@ -329,6 +341,7 @@ function MessageInternal(
|
||||
sendStatus,
|
||||
onResend,
|
||||
onDeleteFailedSend,
|
||||
messageForwardedProps,
|
||||
...props
|
||||
}: MessageProps & { className?: string; children?: ReactNode },
|
||||
ref: any
|
||||
@@ -469,6 +482,8 @@ function MessageInternal(
|
||||
const isFailedSend = sendStatus === EventStatus.NOT_SENT;
|
||||
const canResend = isFailedSend && senderId === mx.getUserId() && !!onResend;
|
||||
const canDeleteFailedSend = isFailedSend && senderId === mx.getUserId() && !!onDeleteFailedSend;
|
||||
// handle clicks on mentions in the message body (e.g. jump to original message from a forwarded message notice)
|
||||
const mentionClickHandler = useMentionClickHandler(room.roomId);
|
||||
|
||||
const handleResendClick: MouseEventHandler<HTMLButtonElement> = useCallback(
|
||||
(evt) => {
|
||||
@@ -500,6 +515,35 @@ function MessageInternal(
|
||||
[css.MessageFailed]: isFailedSend,
|
||||
})}
|
||||
>
|
||||
{messageForwardedProps?.isForwarded && (
|
||||
<Chip as="div" variant="SurfaceVariant" radii="Pill">
|
||||
<Text size="T200" priority="300">
|
||||
Forwarded{' '}
|
||||
{messageForwardedProps.originalEventPrivate ? 'private message' : 'from another room'}{' '}
|
||||
{!messageForwardedProps.originalEventPrivate && (
|
||||
<a
|
||||
href={getMatrixToRoomEvent(
|
||||
messageForwardedProps.originalRoomId,
|
||||
messageForwardedProps.originalEventId
|
||||
)}
|
||||
rel="noreferrer noopener"
|
||||
data-mention-id={messageForwardedProps.originalRoomId}
|
||||
data-mention-event-id={messageForwardedProps.originalEventId}
|
||||
onClick={mentionClickHandler}
|
||||
>
|
||||
jump to original
|
||||
</a>
|
||||
)}
|
||||
<Time
|
||||
ts={messageForwardedProps?.originalTimestamp ?? 0}
|
||||
compact={messageLayout === MessageLayout.Compact}
|
||||
hour24Clock={hour24Clock}
|
||||
dateFormatString={dateFormatString}
|
||||
style={{ marginLeft: config.space.S100, justifyContent: 'flex-end' }}
|
||||
/>
|
||||
</Text>
|
||||
</Chip>
|
||||
)}
|
||||
{reply}
|
||||
{edit && onEditId ? (
|
||||
<MessageEditor
|
||||
@@ -812,6 +856,7 @@ function MessageInternal(
|
||||
<MessageSourceCodeItem room={room} mEvent={mEvent} />
|
||||
)}
|
||||
<MessageCopyLinkItem room={room} mEvent={mEvent} onClose={closeMenu} />
|
||||
<MessageForwardItem room={room} mEvent={mEvent} onClose={closeMenu} />
|
||||
{canPinEvent && (
|
||||
<MessagePinItem room={room} mEvent={mEvent} onClose={closeMenu} />
|
||||
)}
|
||||
@@ -1105,6 +1150,7 @@ export const Event = as<'div', EventProps>(
|
||||
<MessageSourceCodeItem room={room} mEvent={mEvent} />
|
||||
)}
|
||||
<MessageCopyLinkItem room={room} mEvent={mEvent} onClose={closeMenu} />
|
||||
<MessageForwardItem room={room} mEvent={mEvent} onClose={closeMenu} />
|
||||
</Box>
|
||||
{((!mEvent.isRedacted() && canDelete && !stateEvent) ||
|
||||
(mEvent.getSender() !== mx.getUserId() && !stateEvent)) && (
|
||||
|
||||
@@ -172,7 +172,6 @@ function IdentityCosmetics() {
|
||||
const [renderRoomColors, setRenderRoomColors] = useSetting(settingsAtom, 'renderRoomColors');
|
||||
const [renderRoomFonts, setRenderRoomFonts] = useSetting(settingsAtom, 'renderRoomFonts');
|
||||
const [uniformIcons, setUniformIcons] = useSetting(settingsAtom, 'uniformIcons');
|
||||
const [rightBubbles, setRightBubbles] = useSetting(settingsAtom, 'useRightBubbles');
|
||||
|
||||
return (
|
||||
<Box direction="Column" gap="100">
|
||||
@@ -229,13 +228,6 @@ function IdentityCosmetics() {
|
||||
after={<Switch variant="Primary" value={uniformIcons} onChange={setUniformIcons} />}
|
||||
/>
|
||||
</SequenceCard>
|
||||
<SequenceCard className={SequenceCardStyle} variant="SurfaceVariant" direction="Column">
|
||||
<SettingTile
|
||||
title="Right Aligned Bubbles"
|
||||
description="When using bubble layout, have your bubbles right aligned."
|
||||
after={<Switch variant="Primary" value={rightBubbles} onChange={setRightBubbles} />}
|
||||
/>
|
||||
</SequenceCard>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ import {
|
||||
MessageLayout,
|
||||
MessageSpacing,
|
||||
RightSwipeAction,
|
||||
CaptionPosition,
|
||||
settingsAtom,
|
||||
} from '$state/settings';
|
||||
import { SettingTile } from '$components/setting-tile';
|
||||
@@ -42,6 +43,7 @@ import { KeySymbol } from '$utils/key-symbol';
|
||||
import { isMacOS, mobileOrTablet } from '$utils/user-agent';
|
||||
import { stopPropagation } from '$utils/keyboard';
|
||||
import { useMessageLayoutItems } from '$hooks/useMessageLayout';
|
||||
import { useCaptionPositionItems } from '$hooks/useCaptionPosition';
|
||||
import { useMessageSpacingItems } from '$hooks/useMessageSpacing';
|
||||
import { useDateFormatItems } from '$hooks/useDateFormat';
|
||||
import { SequenceCardStyle } from '$features/settings/styles.css';
|
||||
@@ -523,6 +525,74 @@ function SelectMessageLayout() {
|
||||
</>
|
||||
);
|
||||
}
|
||||
function SelectCaptionPosition() {
|
||||
const [menuCords, setMenuCords] = useState<RectCords>();
|
||||
const [captionPosition, setCaptionPosition] = useSetting(settingsAtom, 'captionPosition');
|
||||
const captionPositionItems = useCaptionPositionItems();
|
||||
|
||||
const handleMenu: MouseEventHandler<HTMLButtonElement> = (evt) => {
|
||||
setMenuCords(evt.currentTarget.getBoundingClientRect());
|
||||
};
|
||||
|
||||
const handleSelect = (position: CaptionPosition) => {
|
||||
setCaptionPosition(position);
|
||||
setMenuCords(undefined);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Button
|
||||
size="300"
|
||||
variant="Secondary"
|
||||
outlined
|
||||
fill="Soft"
|
||||
radii="300"
|
||||
after={<Icon size="300" src={Icons.ChevronBottom} />}
|
||||
onClick={handleMenu}
|
||||
>
|
||||
<Text size="T300">
|
||||
{captionPositionItems.find((i) => i.layout === captionPosition)?.name ?? captionPosition}
|
||||
</Text>
|
||||
</Button>
|
||||
<PopOut
|
||||
anchor={menuCords}
|
||||
offset={5}
|
||||
position="Bottom"
|
||||
align="End"
|
||||
content={
|
||||
<FocusTrap
|
||||
focusTrapOptions={{
|
||||
initialFocus: false,
|
||||
onDeactivate: () => setMenuCords(undefined),
|
||||
clickOutsideDeactivates: true,
|
||||
isKeyForward: (evt: KeyboardEvent) =>
|
||||
evt.key === 'ArrowDown' || evt.key === 'ArrowRight',
|
||||
isKeyBackward: (evt: KeyboardEvent) =>
|
||||
evt.key === 'ArrowUp' || evt.key === 'ArrowLeft',
|
||||
escapeDeactivates: stopPropagation,
|
||||
}}
|
||||
>
|
||||
<Menu>
|
||||
<Box direction="Column" gap="100" style={{ padding: config.space.S100 }}>
|
||||
{captionPositionItems.map((item) => (
|
||||
<MenuItem
|
||||
key={item.layout}
|
||||
size="300"
|
||||
variant={captionPosition === item.layout ? 'Primary' : 'Surface'}
|
||||
radii="300"
|
||||
onClick={() => handleSelect(item.layout)}
|
||||
>
|
||||
<Text size="T300">{item.name}</Text>
|
||||
</MenuItem>
|
||||
))}
|
||||
</Box>
|
||||
</Menu>
|
||||
</FocusTrap>
|
||||
}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function SelectMessageSpacing() {
|
||||
const [menuCords, setMenuCords] = useState<RectCords>();
|
||||
@@ -753,6 +823,8 @@ function Messages() {
|
||||
'hideMembershipInReadOnly'
|
||||
);
|
||||
|
||||
const [messageLayout] = useSetting(settingsAtom, 'messageLayout');
|
||||
const [rightBubbles, setRightBubbles] = useSetting(settingsAtom, 'useRightBubbles');
|
||||
return (
|
||||
<Box direction="Column" gap="100">
|
||||
<Text size="L400">Messages</Text>
|
||||
@@ -762,12 +834,24 @@ function Messages() {
|
||||
<SequenceCard className={SequenceCardStyle} variant="SurfaceVariant" direction="Column">
|
||||
<SettingTile title="Message Spacing" after={<SelectMessageSpacing />} />
|
||||
</SequenceCard>
|
||||
<SequenceCard className={SequenceCardStyle} variant="SurfaceVariant" direction="Column">
|
||||
<SettingTile title="File description placement" after={<SelectCaptionPosition />} />
|
||||
</SequenceCard>
|
||||
<SequenceCard className={SequenceCardStyle} variant="SurfaceVariant" direction="Column">
|
||||
<SettingTile
|
||||
title="Emoji Selector Character Threshold"
|
||||
after={<EmojiSelectorThresholdInput />}
|
||||
/>
|
||||
</SequenceCard>
|
||||
{messageLayout === MessageLayout.Bubble && (
|
||||
<SequenceCard className={SequenceCardStyle} variant="SurfaceVariant" direction="Column">
|
||||
<SettingTile
|
||||
title="Right Aligned Bubbles"
|
||||
description="While using bubble layout, have your bubbles right aligned."
|
||||
after={<Switch variant="Primary" value={rightBubbles} onChange={setRightBubbles} />}
|
||||
/>
|
||||
</SequenceCard>
|
||||
)}
|
||||
<SequenceCard className={SequenceCardStyle} variant="SurfaceVariant" direction="Column">
|
||||
<SettingTile
|
||||
title="Hide Membership Change"
|
||||
|
||||
@@ -2,6 +2,8 @@ import { createContext, RefObject, useCallback, useContext, useEffect, useState
|
||||
import { MatrixRTCSession } from 'matrix-js-sdk/lib/matrixrtc/MatrixRTCSession';
|
||||
import { MatrixClient, Room } from 'matrix-js-sdk';
|
||||
import { useSetAtom } from 'jotai';
|
||||
import { settingsAtom } from '$state/settings';
|
||||
import { useSetting } from '$state/hooks/settings';
|
||||
import {
|
||||
CallEmbed,
|
||||
ElementCallThemeKind,
|
||||
@@ -77,6 +79,19 @@ export const useCallStart = (dm = false) => {
|
||||
|
||||
export const useCallJoined = (embed?: CallEmbed): boolean => {
|
||||
const [joined, setJoined] = useState(embed?.joined ?? false);
|
||||
const [allowPip] = useSetting(settingsAtom, 'allowPipVideos');
|
||||
|
||||
if (embed && allowPip) {
|
||||
const removeDisablePictureInPicture = (mutated: any) => {
|
||||
mutated.forEach((event: any) => {
|
||||
Array.from(event.target.getElementsByTagName('video')).forEach((video: any) => {
|
||||
video.removeAttribute('disablepictureinpicture');
|
||||
});
|
||||
});
|
||||
};
|
||||
const pipObserver = new MutationObserver(removeDisablePictureInPicture);
|
||||
pipObserver.observe(embed.iframe.contentDocument!, { subtree: true, childList: true });
|
||||
}
|
||||
|
||||
useClientWidgetApiEvent(
|
||||
embed?.call,
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import { useMemo } from 'react';
|
||||
import { CaptionPosition } from '$state/settings';
|
||||
|
||||
export type MessageLayoutItem = {
|
||||
name: string;
|
||||
layout: CaptionPosition;
|
||||
};
|
||||
|
||||
export const useCaptionPositionItems = (): MessageLayoutItem[] =>
|
||||
useMemo(
|
||||
() => [
|
||||
{
|
||||
layout: CaptionPosition.Above,
|
||||
name: 'Above',
|
||||
},
|
||||
{
|
||||
layout: CaptionPosition.Inline,
|
||||
name: 'Inline',
|
||||
},
|
||||
{
|
||||
layout: CaptionPosition.Hidden,
|
||||
name: 'Hidden',
|
||||
},
|
||||
{
|
||||
layout: CaptionPosition.Below,
|
||||
name: 'Below',
|
||||
},
|
||||
],
|
||||
[]
|
||||
);
|
||||
@@ -241,6 +241,13 @@ export enum Command {
|
||||
SetExt = 'setext',
|
||||
DelExt = 'delext',
|
||||
DiscardSession = 'discardsession',
|
||||
// Cute Events
|
||||
Hug = 'hug',
|
||||
Cuddle = 'cuddle',
|
||||
// our own cute events, not part of FluffyChat or other clients
|
||||
Wave = 'wave',
|
||||
Poke = 'poke',
|
||||
Headpat = 'headpat',
|
||||
}
|
||||
|
||||
export type CommandContent = {
|
||||
@@ -1295,6 +1302,83 @@ export const useCommands = (mx: MatrixClient, room: Room): CommandRecord => {
|
||||
}
|
||||
},
|
||||
},
|
||||
// Cute Events
|
||||
[Command.Hug]: {
|
||||
name: Command.Hug,
|
||||
description: 'Send a hug to someone. Example: /hug [@user:example.org]',
|
||||
exe: async (payload) => {
|
||||
const target = payload.trim();
|
||||
await mx.sendMessage(room.roomId, {
|
||||
msgtype: 'im.fluffychat.cute_event',
|
||||
'm.mentions': {
|
||||
user_ids: target ? [target] : [],
|
||||
},
|
||||
cute_type: 'hug',
|
||||
body: `🤗`,
|
||||
} as any);
|
||||
},
|
||||
},
|
||||
[Command.Cuddle]: {
|
||||
name: Command.Cuddle,
|
||||
description: 'Send a cuddle to someone. Example: /cuddle [@user:example.org]',
|
||||
exe: async (payload) => {
|
||||
const target = payload.trim();
|
||||
await mx.sendMessage(room.roomId, {
|
||||
msgtype: 'im.fluffychat.cute_event',
|
||||
cute_type: 'cuddle',
|
||||
'm.mentions': {
|
||||
user_ids: target ? [target] : [],
|
||||
},
|
||||
body: `😊`,
|
||||
} as any);
|
||||
},
|
||||
},
|
||||
[Command.Wave]: {
|
||||
name: Command.Wave,
|
||||
description: 'Send a wave to someone. Example: /wave [@user:example.org]',
|
||||
exe: async (payload) => {
|
||||
const target = payload.trim();
|
||||
await mx.sendMessage(room.roomId, {
|
||||
msgtype: 'im.fluffychat.cute_event',
|
||||
cute_type: 'wave',
|
||||
'm.mentions': {
|
||||
user_ids: target ? [target] : [],
|
||||
},
|
||||
body: `👋`,
|
||||
} as any);
|
||||
},
|
||||
},
|
||||
[Command.Poke]: {
|
||||
name: Command.Poke,
|
||||
description: 'Send a poke to someone. Example: /poke [@user:example.org]',
|
||||
exe: async (payload) => {
|
||||
const target = payload.trim();
|
||||
await mx.sendMessage(room.roomId, {
|
||||
msgtype: 'im.fluffychat.cute_event',
|
||||
cute_type: 'poke',
|
||||
'm.mentions': {
|
||||
user_ids: target ? [target] : [],
|
||||
},
|
||||
body: `🫵`,
|
||||
} as any);
|
||||
},
|
||||
},
|
||||
[Command.Headpat]: {
|
||||
name: Command.Headpat,
|
||||
description: 'Send a headpat to someone. Example: /headpat [@user:example.org]',
|
||||
// not really like any of the other cute events, but it was too good not to include
|
||||
// using a custom msgtype to avoid confusion with the other existing cute events
|
||||
exe: async (payload) => {
|
||||
const target = payload.trim();
|
||||
await mx.sendMessage(room.roomId, {
|
||||
msgtype: 'fyi.cisnt.headpat',
|
||||
'm.mentions': {
|
||||
user_ids: target ? [target] : [],
|
||||
},
|
||||
body: `*pat pat*`,
|
||||
} as any);
|
||||
},
|
||||
},
|
||||
}),
|
||||
[mx, navigateRoom, room, profile.displayName, profile.avatarUrl, developerTools]
|
||||
);
|
||||
|
||||
@@ -304,7 +304,8 @@ function MessageNotifications() {
|
||||
|
||||
// Page is visible — show the themed in-app notification banner for any
|
||||
// highlighted message (mention / keyword) or loud push rule.
|
||||
if (showNotifications && (isHighlightByRule || loudByRule || isDM)) {
|
||||
// okay fast patch because that showNotifications setting atom is not getting set correctly or something
|
||||
if (mobileOrTablet() && showNotifications && (isHighlightByRule || loudByRule || isDM)) {
|
||||
const isEncryptedRoom = !!getStateEvent(room, StateEvent.RoomEncryption);
|
||||
const avatarMxc =
|
||||
room.getAvatarFallbackMember()?.getMxcAvatarUrl() ?? room.getMxcAvatarUrl();
|
||||
|
||||
@@ -3,6 +3,8 @@ import { MatrixEvent, Room, Relations } from '$types/matrix-sdk';
|
||||
|
||||
export enum ModalType {
|
||||
Delete = 'delete',
|
||||
// for forwarding a message to another room, not to be confused with the "share" action which is for sharing a message to another app
|
||||
Forward = 'forward',
|
||||
Report = 'report',
|
||||
Source = 'source',
|
||||
Reactions = 'reactions',
|
||||
@@ -11,6 +13,7 @@ export enum ModalType {
|
||||
|
||||
export type ModalState =
|
||||
| { type: ModalType.Delete; room: Room; mEvent: MatrixEvent }
|
||||
| { type: ModalType.Forward; room: Room; mEvent: MatrixEvent }
|
||||
| { type: ModalType.Report; room: Room; mEvent: MatrixEvent }
|
||||
| { type: ModalType.Source; room: Room; mEvent: MatrixEvent }
|
||||
| { type: ModalType.Reactions; room: Room; relations: Relations }
|
||||
|
||||
@@ -15,6 +15,12 @@ export enum RightSwipeAction {
|
||||
Reply = 'reply',
|
||||
}
|
||||
|
||||
export enum CaptionPosition {
|
||||
Above = 'above',
|
||||
Inline = 'inline',
|
||||
Hidden = 'hidden',
|
||||
Below = 'below',
|
||||
}
|
||||
export type JumboEmojiSize = 'none' | 'extraSmall' | 'small' | 'normal' | 'large' | 'extraLarge';
|
||||
|
||||
export interface Settings {
|
||||
@@ -69,6 +75,7 @@ export interface Settings {
|
||||
filterPronounsLanguages?: string[];
|
||||
renderRoomColors: boolean;
|
||||
renderRoomFonts: boolean;
|
||||
captionPosition: CaptionPosition;
|
||||
|
||||
// Sable features!
|
||||
mobileGestures: boolean;
|
||||
@@ -143,6 +150,7 @@ const defaultSettings: Settings = {
|
||||
renderGlobalNameColors: true,
|
||||
renderRoomColors: true,
|
||||
renderRoomFonts: true,
|
||||
captionPosition: CaptionPosition.Below,
|
||||
|
||||
// Sable features!
|
||||
mobileGestures: true,
|
||||
|
||||
@@ -10,6 +10,8 @@ import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfil
|
||||
import inject from '@rollup/plugin-inject';
|
||||
import topLevelAwait from 'vite-plugin-top-level-await';
|
||||
import { VitePWA } from 'vite-plugin-pwa';
|
||||
import { compression, defineAlgorithm } from 'vite-plugin-compression2';
|
||||
import { constants as zlibConstants } from 'zlib';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { cloudflare } from '@cloudflare/vite-plugin';
|
||||
@@ -183,6 +185,14 @@ export default defineConfig({
|
||||
},
|
||||
},
|
||||
}),
|
||||
compression({
|
||||
algorithms: [
|
||||
defineAlgorithm('brotliCompress', {
|
||||
params: { [zlibConstants.BROTLI_PARAM_QUALITY]: zlibConstants.BROTLI_MAX_QUALITY },
|
||||
}),
|
||||
],
|
||||
include: /\.(html|xml|css|json|js|mjs|svg|yaml|yml|toml|wasm|txt|map)$/,
|
||||
}),
|
||||
],
|
||||
optimizeDeps: {
|
||||
// Rebuild dep optimizer cache on each dev start to avoid stale API shapes.
|
||||
|
||||
Reference in new issue
Block a user