Merge remote-tracking branch 'upstream/dev' into sable-edit-history

This commit is contained in:
Shea Duma committed 2026-03-09 02:37:36 +02:00
commit d0e5d7c9ec
33 files changed
+645 -156

No files matched your search

+23
View File
@@ -1,5 +1,28 @@
# Sable Client Changelog
## 1.5.3 (2026-03-08)
### Fixes
* Fix scroll clamping to bottom while scrolling up.
* Fix message links sometimes scrolling to bottom of timeline instead of message + maybe other scroll bugs.
* Merge upstream call fixes
* Fix crash when invalid location events are sent.
* Add rendering of per-message-profiles.
* custom emojis are now also visible in forwards, instead of being reduced to it's shortcode
* fix: default badge unread counts to off
## 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
+1 -1
View File
@@ -4,7 +4,7 @@
}
}
:80 {
:8080 {
root * /app
# Enable on-the-fly compression for things not pre-compressed
+6
View File
@@ -21,5 +21,11 @@ COPY --from=builder /src/dist /
## App
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 Caddyfile /etc/caddy/Caddyfile
+2 -2
View File
@@ -29,7 +29,7 @@ Prebuilt images are published to `ghcr.io/7w1/sable`.
Run the latest image with:
```sh
docker run --rm -p 8080:80 ghcr.io/7w1/sable:latest
docker run --rm -p 8080:8080 ghcr.io/7w1/sable:latest
```
Then open `http://localhost:8080`.
@@ -42,7 +42,7 @@ services:
sable:
image: ghcr.io/7w1/sable:latest
ports:
- '8080:80'
- '8080:8080'
volumes:
- ./config.json:/app/config.json:ro
```
+1 -1
View File
@@ -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>
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "sable",
"version": "1.5.1",
"version": "1.5.3",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "sable",
"version": "1.5.1",
"version": "1.5.3",
"hasInstallScript": true,
"license": "AGPL-3.0-only",
"dependencies": {
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "sable",
"version": "1.5.1",
"version": "1.5.3",
"description": "Yet another matrix client fork",
"type": "module",
"packageManager": "[email protected]",
+2
View File
@@ -6,6 +6,7 @@ import {
useCallHangupEvent,
useCallJoined,
useCallThemeSync,
useCallMemberSoundSync,
} from '../hooks/useCallEmbed';
import { callChatAtom, callEmbedAtom } from '../state/callEmbed';
import { CallEmbed } from '../plugins/call';
@@ -15,6 +16,7 @@ import { ScreenSize, useScreenSizeContext } from '../hooks/useScreenSize';
function CallUtils({ embed }: { embed: CallEmbed }) {
const setCallEmbed = useSetAtom(callEmbedAtom);
useCallMemberSoundSync(embed);
useCallThemeSync(embed);
useCallHangupEvent(
embed,
@@ -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;
@@ -348,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 />;
}
+1 -1
View File
@@ -4,7 +4,7 @@ import { DefaultReset } from 'folds';
export const Image = style([
DefaultReset,
{
objectFit: 'cover',
objectFit: 'contain',
width: '100%',
height: '100%',
},
+62
View File
@@ -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>
);
}
@@ -250,19 +250,26 @@ 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
style={{
flexGrow: 1,
flexShrink: 0,
width: toRem(displayWidth),
}}
outlined={outlined}
>
<AttachmentBox
style={{
height: toRem(height < 48 ? 48 : height),
aspectRatio,
maxHeight: toRem(MAX_SIZE),
}}
>
{renderImageContent({
@@ -306,7 +313,7 @@ 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';
@@ -455,7 +462,10 @@ type MLocationProps = {
export function MLocation({ content }: MLocationProps) {
const geoUri = content.geo_uri;
if (typeof geoUri !== 'string') return <BrokenContent />;
const location = parseGeoUri(geoUri);
if (!location) return <BrokenContent />;
return (
<Box direction="Column" alignItems="Start" gap="100">
<Text size="T400">{geoUri}</Text>
@@ -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([
@@ -153,26 +153,52 @@ export function MessageForwardInternal({ room, mEvent, onClose }: MessageForward
type SendEventContent = Parameters<typeof mx.sendEvent>[3];
const eventType = mEvent.getType() as SendEventType;
const originalContent = mEvent.getContent();
const isTextMessage = originalContent.msgtype === 'm.text';
// 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')})`;
const originalBody = typeof originalContent.body === 'string' ? originalContent.body : '';
const originalFormattedBody =
originalContent.format === 'org.matrix.custom.html' &&
typeof originalContent.formatted_body === 'string'
? originalContent.formatted_body
: undefined;
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
if (isTextMessage) {
const quotedBody = originalBody
.split('\n')
.map((l: string) => `> ${l}`)
.join('\n')}`;
const safeHtml = sanitizeCustomHtml(original).replace(/\n/g, '<br>');
.map((line) => `> ${line}`)
.join('\n');
newBodyPlain = originalBody.length > 0 ? `${bodyModifText}\n\n${quotedBody}` : bodyModifText;
const safeHtml =
originalFormattedBody !== undefined
? sanitizeCustomHtml(originalFormattedBody)
: sanitizeCustomHtml(originalBody).replace(/\n/g, '<br>');
newBodyHtml =
`<div class="forwarded" data-forward-marker>` +
`<div data-forward-marker>` +
`<p>${sanitizeCustomHtml(bodyModifText)}</p>` +
`<blockquote>${safeHtml}</blockquote>` +
`</div>`;
}
// the quoted body
const forwardedTextContent = isTextMessage
? {
body: newBodyPlain,
format: 'org.matrix.custom.html',
formatted_body: newBodyHtml,
}
: {};
let content;
// handle privacy stuff
if (isPrivate) {
@@ -180,9 +206,7 @@ export function MessageForwardInternal({ room, mEvent, onClose }: MessageForward
// 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,
...forwardedTextContent,
'moe.sable.message.forward': {
v: 1,
is_forwarded: true,
@@ -193,9 +217,7 @@ export function MessageForwardInternal({ room, mEvent, onClose }: MessageForward
} else {
content = {
...mEvent.getContent(),
body: newBodyPlain,
format: 'org.matrix.custom.html',
formatted_body: newBodyHtml,
...forwardedTextContent,
'm.relates_to': {
rel_type: 'm.reference',
event_id: eventId,
@@ -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}
+8 -11
View File
@@ -20,12 +20,12 @@ function MicrophoneButton({ enabled, onToggle }: MicrophoneButtonProps) {
{(anchorRef) => (
<IconButton
ref={anchorRef}
variant={enabled ? 'Background' : 'Warning'}
variant={enabled ? 'Surface' : 'Warning'}
fill="Soft"
radii="300"
size="300"
onClick={() => onToggle()}
outlined={!enabled}
outlined
>
<Icon size="100" src={enabled ? Icons.Mic : Icons.MicMute} filled={!enabled} />
</IconButton>
@@ -51,12 +51,12 @@ function SoundButton({ enabled, onToggle }: SoundButtonProps) {
{(anchorRef) => (
<IconButton
ref={anchorRef}
variant={enabled ? 'Background' : 'Warning'}
variant={enabled ? 'Surface' : 'Warning'}
fill="Soft"
radii="300"
size="300"
onClick={() => onToggle()}
outlined={!enabled}
outlined
>
<Icon
size="100"
@@ -86,12 +86,12 @@ function VideoButton({ enabled, onToggle }: VideoButtonProps) {
{(anchorRef) => (
<IconButton
ref={anchorRef}
variant={enabled ? 'Success' : 'Background'}
variant={enabled ? 'Success' : 'Surface'}
fill="Soft"
radii="300"
size="300"
onClick={() => onToggle()}
outlined={enabled}
outlined
>
<Icon
size="100"
@@ -119,12 +119,12 @@ function ScreenShareButton() {
{(anchorRef) => (
<IconButton
ref={anchorRef}
variant={enabled ? 'Success' : 'Background'}
variant={enabled ? 'Success' : 'Surface'}
fill="Soft"
radii="300"
size="300"
onClick={() => setEnabled(!enabled)}
outlined={enabled}
outlined
>
<Icon size="100" src={Icons.ScreenShare} filled={enabled} />
</IconButton>
@@ -144,9 +144,6 @@ export function CallControl({ callEmbed }: { callEmbed: CallEmbed }) {
onToggle={() => callEmbed.control.toggleMicrophone()}
/>
<SoundButton enabled={sound} onToggle={() => callEmbed.control.toggleSound()} />
</Box>
<StatusDivider />
<Box alignItems="Inherit" gap="200">
<VideoButton enabled={video} onToggle={() => callEmbed.control.toggleVideo()} />
{false && <ScreenShareButton />}
</Box>
+34 -9
View File
@@ -11,6 +11,8 @@ import { MemberGlance } from './MemberGlance';
import { StatusDivider } from './components';
import { CallEmbed } from '../../plugins/call/CallEmbed';
import { useCallJoined } from '../../hooks/useCallEmbed';
import { useCallSpeakers } from '../../hooks/useCallSpeakers';
import { MemberSpeaking } from './MemberSpeaking';
type CallStatusProps = {
callEmbed: CallEmbed;
@@ -22,28 +24,51 @@ export function CallStatus({ callEmbed }: CallStatusProps) {
const callMembers = useCallMembers(room, callSession);
const screenSize = useScreenSize();
const callJoined = useCallJoined(callEmbed);
const speakers = useCallSpeakers(callEmbed);
const compact = screenSize === ScreenSize.Mobile;
const memberVisible = callJoined && callMembers.length > 0;
return (
<Box
className={classNames(css.CallStatus, ContainerColor({ variant: 'Background' }))}
shrink="No"
gap="400"
alignItems="Center"
direction={screenSize === ScreenSize.Mobile ? 'Column' : 'Row'}
alignItems={compact ? undefined : 'Center'}
direction={compact ? 'Column' : 'Row'}
>
<Box grow="Yes" alignItems="Inherit" gap="200">
{callJoined && callMembers.length > 0 ? (
<Box shrink="No" gap="Inherit" alignItems="Inherit">
<MemberGlance room={room} members={callMembers} />
<Box grow="Yes" alignItems="Center" gap="200">
{memberVisible ? (
<Box shrink="No">
<LiveChip count={callMembers.length} room={room} members={callMembers} />
</Box>
) : (
<Spinner variant="Secondary" size="200" />
)}
<StatusDivider />
<CallRoomName room={room} />
<Box
grow="Yes"
alignItems="Center"
gap="Inherit"
justifyContent={compact ? 'Center' : undefined}
>
<CallRoomName room={room} />
{speakers.size > 0 && !compact && (
<>
<StatusDivider />
<span data-spacing-node />
<MemberSpeaking room={room} speakers={speakers} />
</>
)}
</Box>
{memberVisible && (
<Box shrink="No">
<MemberGlance room={room} members={callMembers} speakers={speakers} />
</Box>
)}
</Box>
<Box shrink="No" alignItems="Inherit" gap="Inherit">
{memberVisible && !compact && <StatusDivider />}
<Box shrink="No" alignItems="Center" justifyContent="Center" gap="Inherit">
<CallControl callEmbed={callEmbed} />
</Box>
</Box>
@@ -9,13 +9,15 @@ import { useMediaAuthentication } from '../../hooks/useMediaAuthentication';
import { StackedAvatar } from '../../components/stacked-avatar';
import { useOpenUserRoomProfile } from '../../state/hooks/userRoomProfile';
import { getMouseEventCords } from '../../utils/dom';
import * as css from './styles.css';
type MemberGlanceProps = {
room: Room;
members: CallMembership[];
speakers: Set<string>;
max?: number;
};
export function MemberGlance({ room, members, max = 6 }: MemberGlanceProps) {
export function MemberGlance({ room, members, speakers, max = 6 }: MemberGlanceProps) {
const mx = useMatrixClient();
const useAuthentication = useMediaAuthentication();
const openUserProfile = useOpenUserRoomProfile();
@@ -37,6 +39,7 @@ export function MemberGlance({ room, members, max = 6 }: MemberGlanceProps) {
return (
<StackedAvatar
key={callMember.membershipID}
className={speakers.has(callMember.sender) ? css.SpeakerAvatarOutline : undefined}
title={name}
as="button"
variant="Background"
@@ -0,0 +1,77 @@
import { Room } from 'matrix-js-sdk';
import { Box, Icon, Icons, Text } from 'folds';
import { getMemberDisplayName } from '../../utils/room';
import { getMxIdLocalPart } from '../../utils/matrix';
type MemberSpeakingProps = {
room: Room;
speakers: Set<string>;
};
export function MemberSpeaking({ room, speakers }: MemberSpeakingProps) {
const speakingNames = Array.from(speakers).map(
(userId) => getMemberDisplayName(room, userId) ?? getMxIdLocalPart(userId) ?? userId
);
return (
<Box alignItems="Center" gap="100">
<Icon size="100" src={Icons.Phone} filled />
<Text size="T200" truncate>
{speakingNames.length === 1 && (
<>
<b>{speakingNames[0]}</b>
<Text as="span" size="Inherit" priority="300">
{' is speaking...'}
</Text>
</>
)}
{speakingNames.length === 2 && (
<>
<b>{speakingNames[0]}</b>
<Text as="span" size="Inherit" priority="300">
{' and '}
</Text>
<b>{speakingNames[1]}</b>
<Text as="span" size="Inherit" priority="300">
{' are speaking...'}
</Text>
</>
)}
{speakingNames.length === 3 && (
<>
<b>{speakingNames[0]}</b>
<Text as="span" size="Inherit" priority="300">
{', '}
</Text>
<b>{speakingNames[1]}</b>
<Text as="span" size="Inherit" priority="300">
{' and '}
</Text>
<b>{speakingNames[2]}</b>
<Text as="span" size="Inherit" priority="300">
{' are speaking...'}
</Text>
</>
)}
{speakingNames.length > 3 && (
<>
<b>{speakingNames[0]}</b>
<Text as="span" size="Inherit" priority="300">
{', '}
</Text>
<b>{speakingNames[1]}</b>
<Text as="span" size="Inherit" priority="300">
{', '}
</Text>
<b>{speakingNames[2]}</b>
<Text as="span" size="Inherit" priority="300">
{' and '}
</Text>
<b>{speakingNames.length - 3} others</b>
<Text as="span" size="Inherit" priority="300">
{' are speaking...'}
</Text>
</>
)}
</Text>
</Box>
);
}
@@ -15,3 +15,7 @@ export const CallStatus = style([
export const ControlDivider = style({
height: toRem(16),
});
export const SpeakerAvatarOutline = style({
boxShadow: `0 0 0 ${config.borderWidth.B600} ${color.Success.Main}`,
});
+2 -2
View File
@@ -1,7 +1,7 @@
import { useRef } from 'react';
import { Badge, Box, color, Header, Scroll, Text, toRem } from 'folds';
import { EventType } from '$types/matrix-sdk';
import { useCallEmbed, useCallJoined, useSyncCallEmbedPlacement } from '$hooks/useCallEmbed';
import { useCallEmbed, useCallEmbedPlacementSync, useCallJoined } from '$hooks/useCallEmbed';
import { ContainerColor } from '$styles/ContainerColor.css';
import { usePowerLevelsContext } from '$hooks/usePowerLevels';
import { useRoom } from '$hooks/useRoom';
@@ -44,7 +44,7 @@ export function CallView() {
const room = useRoom();
const callViewRef = useRef<HTMLDivElement>(null);
useSyncCallEmbedPlacement(callViewRef);
useCallEmbedPlacementSync(callViewRef);
const powerLevels = usePowerLevelsContext();
const creators = useRoomCreators(room);
+25 -36
View File
@@ -103,7 +103,6 @@ import {
useIntersectionObserver,
} from '$hooks/useIntersectionObserver';
import { markAsRead } from '$utils/notifications';
import { useDebounce } from '$hooks/useDebounce';
import { getResizeObserverEntry, useResizeObserver } from '$hooks/useResizeObserver';
import { inSameDay, minuteDifference, timeDayMonthYear, today, yesterday } from '$utils/time';
import { createMentionElement, isEmptyEditor, moveCursor } from '$components/editor';
@@ -620,9 +619,13 @@ export function RoomTimeline({
}
const atBottomAnchorRef = useRef<HTMLElement>(null);
const [atBottom, setAtBottom] = useState<boolean>(true);
const [atBottom, setAtBottomState] = useState<boolean>(true);
const atBottomRef = useRef(atBottom);
atBottomRef.current = atBottom;
const setAtBottom = useCallback((val: boolean) => {
setAtBottomState(val);
atBottomRef.current = val;
}, []);
const scrollRef = useRef<HTMLDivElement>(null);
const scrollToBottomRef = useRef({
@@ -734,6 +737,7 @@ export function RoomTimeline({
if (!alive()) return;
const evLength = getTimelinesEventsCount(lTimelines);
setAtBottom(false);
setFocusItem({
index: evtAbsIndex,
scrollTo: true,
@@ -747,7 +751,7 @@ export function RoomTimeline({
},
});
},
[alive]
[alive, setAtBottom]
),
useCallback(() => {
if (!alive()) return;
@@ -829,6 +833,8 @@ export function RoomTimeline({
evtTimeline && getEventIdAbsoluteIndex(timeline.linkedTimelines, evtTimeline, evtId);
if (typeof absoluteIndex === 'number') {
setAtBottom(false);
const scrolled = scrollToItem(absoluteIndex, {
behavior: reducedMotion ? 'instant' : 'smooth',
align: 'center',
@@ -837,14 +843,14 @@ export function RoomTimeline({
if (onScroll) onScroll(scrolled);
setFocusItem({
index: absoluteIndex,
scrollTo: false,
scrollTo: !scrolled,
highlight,
});
} else {
loadEventTimeline(evtId);
}
},
[room, timeline, scrollToItem, loadEventTimeline, reducedMotion]
[room, timeline, scrollToItem, loadEventTimeline, reducedMotion, setAtBottom]
);
useLiveTimelineRefresh(
@@ -910,29 +916,26 @@ export function RoomTimeline({
}
}, [mx, room, hideReads]);
const debounceSetAtBottom = useDebounce(
useCallback((entry: IntersectionObserverEntry) => {
if (!entry.isIntersecting) setAtBottom(false);
}, []),
{ wait: 1000 }
);
useIntersectionObserver(
useCallback(
(entries) => {
const target = atBottomAnchorRef.current;
if (!target) return;
const targetEntry = getIntersectionObserverEntry(target, entries);
if (targetEntry) debounceSetAtBottom(targetEntry);
if (targetEntry?.isIntersecting) {
// Track scroll position independently of atLiveEndRef so that atBottom
// is always accurate. tryAutoMarkAsRead still requires atLiveEndRef.
if (!targetEntry) return;
if (targetEntry.isIntersecting) {
// User has reached the bottom
setAtBottom(true);
if (atLiveEndRef.current && document.hasFocus()) {
tryAutoMarkAsRead();
}
} else {
// User has intentionally scrolled up.
setAtBottom(false);
}
},
[debounceSetAtBottom, tryAutoMarkAsRead]
[tryAutoMarkAsRead, setAtBottom]
),
useCallback(
() => ({
@@ -1006,36 +1009,20 @@ export function RoomTimeline({
const contentEl = scrollEl?.firstElementChild as HTMLElement;
if (!scrollEl || !contentEl) return () => {};
let lastScrollTop = scrollEl.scrollTop;
let userIsScrollingUp = false;
// Track if user is scrolling up
const handleScroll = () => {
if (scrollEl.scrollTop < lastScrollTop) {
userIsScrollingUp = true;
} else if (scrollEl.scrollHeight - scrollEl.scrollTop <= scrollEl.clientHeight + 10) {
userIsScrollingUp = false;
}
lastScrollTop = scrollEl.scrollTop;
};
const forceScroll = () => {
// if the user isn't scrolling jump down to latest content
if (!userIsScrollingUp) {
scrollToBottom(scrollEl, 'instant');
}
if (!atBottomRef.current) return;
scrollToBottom(scrollEl, 'instant');
};
const resizeObserver = new ResizeObserver(() => {
requestAnimationFrame(forceScroll);
});
scrollEl.addEventListener('scroll', handleScroll, { passive: true });
resizeObserver.observe(contentEl);
return () => {
resizeObserver.disconnect();
scrollEl.removeEventListener('scroll', handleScroll);
};
}, [room]);
@@ -1090,7 +1077,9 @@ export function RoomTimeline({
// reach the true bottom (e.g. after images finish loading or the
// virtual keyboard shifts the viewport).
if (behavior === 'instant') {
setTimeout(() => scrollToBottom(scrollEl, 'instant'), 80);
setTimeout(() => {
scrollToBottom(scrollEl, 'instant');
}, 80);
}
}
}
+22 -5
View File
@@ -350,6 +350,18 @@ function MessageInternal(
const mx = useMatrixClient();
const useAuthentication = useMediaAuthentication();
const pmp = useMemo(
() =>
mEvent.event.content?.['com.beeper.per_message_profile'] as
| {
avatar_url: string | undefined;
displayname: string | undefined;
id: string | undefined;
}
| undefined,
[mEvent]
);
// Profiles and Colors
const profile = useUserProfile(senderId, room);
const { color: usernameColor, font: usernameFont } = useSableCosmetics(senderId, room);
@@ -359,9 +371,14 @@ function MessageInternal(
// avatar so per-room avatar overrides are respected in the timeline.
const avatarUrl = useMemo(() => {
if (collapse) return undefined;
const mxc = getMemberAvatarMxc(room, senderId) || profile.avatarUrl;
const mxc = pmp?.avatar_url || getMemberAvatarMxc(room, senderId) || profile.avatarUrl;
return mxc ? mxcUrlToHttp(mx, mxc, useAuthentication, 48, 48, 'crop') : undefined;
}, [collapse, profile.avatarUrl, senderId, mx, room, useAuthentication]);
}, [pmp, collapse, profile.avatarUrl, senderId, mx, room, useAuthentication]);
const displayName = useMemo(
() => pmp?.displayname || senderDisplayName,
[pmp, senderDisplayName]
);
const cachedAvatar = useBlobCache(avatarUrl ?? undefined);
@@ -425,7 +442,7 @@ function MessageInternal(
onClick={onUsernameClick}
>
<Text as="span" size={messageLayout === MessageLayout.Bubble ? 'T300' : 'T400'} truncate>
<UsernameBold>{senderDisplayName}</UsernameBold>
<UsernameBold>{displayName}</UsernameBold>
</Text>
</Username>
{showPronouns && (
@@ -468,7 +485,7 @@ function MessageInternal(
<UserAvatar
userId={senderId}
src={cachedAvatar}
alt={senderDisplayName}
alt={displayName}
renderFallback={() => <Icon size="200" src={Icons.User} filled />}
/>
</Avatar>
@@ -882,7 +899,7 @@ function MessageInternal(
autoFocus
value={nickDraft}
onChange={(e) => setNickDraft(e.target.value)}
placeholder={senderDisplayName}
placeholder={displayName}
onKeyDown={(e) => {
if (e.key === 'Enter') {
setNickname(senderId, nickDraft || undefined, mx);
+9
View File
@@ -53,3 +53,12 @@ export const useCallMembers = (room: Room, session: MatrixRTCSession): CallMembe
return memberships;
};
export const useCallMembersChange = (session: MatrixRTCSession, callback: () => void): void => {
useEffect(() => {
session.on(MatrixRTCSessionEvent.MembershipsChanged, callback);
return () => {
session.removeListener(MatrixRTCSessionEvent.MembershipsChanged, callback);
};
}, [session, callback]);
};
+25 -1
View File
@@ -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,
@@ -13,6 +15,7 @@ import { ThemeKind, useTheme } from './useTheme';
import { callEmbedAtom } from '../state/callEmbed';
import { useResizeObserver } from './useResizeObserver';
import { CallControlState } from '../plugins/call/CallControlState';
import { useCallMembersChange, useCallSession } from './useCall';
const CallEmbedContext = createContext<CallEmbed | undefined>(undefined);
@@ -77,6 +80,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,
@@ -99,6 +115,14 @@ export const useCallHangupEvent = (embed: CallEmbed, callback: () => void) => {
useClientWidgetApiEvent(embed.call, ElementWidgetActions.HangupCall, callback);
};
export const useCallMemberSoundSync = (embed: CallEmbed) => {
const callSession = useCallSession(embed.room);
useCallMembersChange(
callSession,
useCallback(() => embed.control.applySound(), [embed])
);
};
export const useCallThemeSync = (embed: CallEmbed) => {
const theme = useTheme();
@@ -109,7 +133,7 @@ export const useCallThemeSync = (embed: CallEmbed) => {
}, [theme.kind, embed]);
};
export const useSyncCallEmbedPlacement = (containerViewRef: RefObject<HTMLDivElement>): void => {
export const useCallEmbedPlacementSync = (containerViewRef: RefObject<HTMLDivElement>): void => {
const callEmbedRef = useCallEmbedRef();
const syncCallEmbedPlacement = useCallback(() => {
+60
View File
@@ -0,0 +1,60 @@
import { useCallback, useEffect, useMemo, useState } from 'react';
import { CallEmbed } from '../plugins/call';
import { useMutationObserver } from './useMutationObserver';
import { isUserId } from '../utils/matrix';
import { useCallMembers, useCallSession } from './useCall';
import { useCallJoined } from './useCallEmbed';
export const useCallSpeakers = (callEmbed: CallEmbed): Set<string> => {
const [speakers, setSpeakers] = useState(new Set<string>());
const callSession = useCallSession(callEmbed.room);
const callMembers = useCallMembers(callEmbed.room, callSession);
const joined = useCallJoined(callEmbed);
const videoContainers = useMemo(() => {
if (callMembers && joined) return callEmbed.document?.querySelectorAll('[data-video-fit]');
return undefined;
}, [callEmbed, callMembers, joined]);
const mutationObserver = useMutationObserver(
useCallback(
(mutations) => {
const s = new Set<string>();
mutations.forEach((mutation) => {
if (mutation.type !== 'attributes') return;
const el = mutation.target as HTMLElement;
const style = callEmbed.iframe.contentWindow?.getComputedStyle(el, '::before');
if (!style) return;
const tileBackgroundImage = style.getPropertyValue('background-image');
const speaking = tileBackgroundImage !== 'none';
if (!speaking) return;
const speakerId = el.querySelector('[aria-label]')?.getAttribute('aria-label');
if (speakerId && isUserId(speakerId)) {
s.add(speakerId);
}
});
setSpeakers(s);
},
[callEmbed]
)
);
useEffect(() => {
videoContainers?.forEach((element) => {
mutationObserver.observe(element, {
attributes: true,
attributeFilter: ['class', 'style'],
});
});
return () => {
mutationObserver.disconnect();
};
}, [videoContainers, mutationObserver]);
return speakers;
};
+84
View File
@@ -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]
);
+37
View File
@@ -0,0 +1,37 @@
import { useEffect, useMemo } from 'react';
export type OnMutationCallback = (mutations: MutationRecord[]) => void;
export const getMutationRecord = (
target: Node,
mutations: MutationRecord[]
): MutationRecord | undefined => mutations.find((mutation) => mutation.target === target);
export const useMutationObserver = (
onMutationCallback: OnMutationCallback,
observeElement?: Node | null | (() => Node | null),
options?: MutationObserverInit
): MutationObserver => {
const mutationObserver = useMemo(
() => new MutationObserver(onMutationCallback),
[onMutationCallback]
);
useEffect(() => () => mutationObserver?.disconnect(), [mutationObserver]);
useEffect(() => {
const element = typeof observeElement === 'function' ? observeElement() : observeElement;
if (element) {
mutationObserver.observe(element, options);
}
return () => {
if (element) {
mutationObserver.disconnect();
}
};
}, [mutationObserver, observeElement, options]);
return mutationObserver;
};
+6 -4
View File
@@ -47,6 +47,10 @@ export class CallControl extends EventEmitter implements CallControlState {
this.emitStateUpdate();
}
public applySound() {
this.setSound(this.sound);
}
private setMediaState(state: ElementMediaStatePayload) {
return this.call.transport.send(ElementWidgetActions.DeviceMute, state);
}
@@ -55,10 +59,8 @@ export class CallControl extends EventEmitter implements CallControlState {
const callDocument = this.iframe.contentDocument ?? this.iframe.contentWindow?.document;
if (callDocument) {
callDocument.querySelectorAll('audio').forEach((el) => {
if (el instanceof HTMLAudioElement) {
// eslint-disable-next-line no-param-reassign
el.muted = !sound;
}
// eslint-disable-next-line no-param-reassign
el.muted = !sound;
});
}
}
+4
View File
@@ -163,6 +163,10 @@ export class CallEmbed {
return this.room.roomId;
}
get document(): Document | undefined {
return this.iframe.contentDocument ?? this.iframe.contentWindow?.document;
}
public setTheme(theme: ElementCallThemeKind) {
return this.call.transport.send(WidgetApiToWidgetAction.ThemeChange, {
name: theme,
+1 -1
View File
@@ -157,7 +157,7 @@ const defaultSettings: Settings = {
rightSwipeAction: RightSwipeAction.Reply,
hideMembershipInReadOnly: true,
useRightBubbles: false,
showUnreadCounts: true,
showUnreadCounts: false,
badgeCountDMsOnly: false,
showPingCounts: true,
hideReads: false,
+8
View File
@@ -87,9 +87,17 @@ export const scaleYDimension = (x: number, scaledX: number, y: number): number =
};
export const parseGeoUri = (location: string) => {
if (!location) return null;
const [, data] = location.split(':');
if (!data) return null;
const [cords] = data.split(';');
if (!cords) return null;
const [latitude, longitude] = cords.split(',');
if (!latitude || !longitude) return null;
return {
latitude,
longitude,