Skip to content

Commit c223f35

Browse files
authored
Various small fixes (#772)
<!-- Please read https://github.com/SableClient/Sable/blob/dev/CONTRIBUTING.md before submitting your pull request --> ### Description <!-- Please include a summary of the change. Please also include relevant motivation and context. List any dependencies that are required for this change. --> Adds arrow brackets back to suppressed previews when editing messages. Adds back the height attribute and adds settings for adjusting the maximum and default incoming inline image height. Fixed the read receipt dialog inconsistency. Fixes the room cosmetics menu not properly updating the membership with the new avatar. Fixes #767 Fixes #770 #### Type of change - [x] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update ### Checklist: - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings ### AI disclosure: - [x] Partially AI assisted (clarify which code was AI assisted and briefly explain what it does). - [ ] Fully AI generated (explain what all the generated code does in moderate detail). <!-- Write any explanation required here, but do not generate the explanation using AI!! You must prove you understand what the code in this PR does. --> Tests were AI generated
2 parents f07fb1b + a76f451 commit c223f35

31 files changed

Lines changed: 721 additions & 235 deletions
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
default: patch
3+
---
4+
5+
Added a couple new settings for max incoming inline image height and default height for unspecified.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
default: patch
3+
---
4+
5+
Fixed links with suppressed previews not having the arrow brackets readded when editing a message.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
default: patch
3+
---
4+
5+
Fix the inconsistent sizing for the read receipt dialog boxes.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
default: patch
3+
---
4+
5+
Fixed room avatars set in the settings cosmetics menu not applying.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { describe, expect, it } from 'vitest';
2+
import { toMatrixCustomHTML, trimCustomHtml } from '$components/editor/output';
3+
import { BlockType } from '$components/editor/types';
4+
5+
describe('toMatrixCustomHTML emoticons', () => {
6+
it('always serializes custom emoji images with height=32', () => {
7+
const html = trimCustomHtml(
8+
toMatrixCustomHTML(
9+
[
10+
{
11+
type: BlockType.Paragraph,
12+
children: [
13+
{
14+
type: BlockType.Emoticon,
15+
key: 'mxc://example.org/emote',
16+
shortcode: 'blobcat',
17+
children: [{ text: '' }],
18+
} as never,
19+
],
20+
} as never,
21+
],
22+
{}
23+
)
24+
);
25+
26+
expect(html).toContain('data-mx-emoticon');
27+
expect(html).toContain('mxc://example.org/emote');
28+
expect(html).toContain('height="32"');
29+
});
30+
});

src/app/components/event-readers/EventReaders.css.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export const EventReaders = style([
55
DefaultReset,
66
{
77
height: '100%',
8+
width: '280px',
89
},
910
]);
1011

@@ -18,4 +19,6 @@ export const Header = style({
1819
export const Content = style({
1920
paddingLeft: config.space.S200,
2021
paddingBottom: config.space.S400,
22+
width: '100%',
23+
minWidth: 0,
2124
});

src/app/components/event-readers/EventReaders.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,14 @@ export const EventReaders = as<'div', EventReadersProps>(
5858
<Icon src={Icons.Cross} />
5959
</IconButton>
6060
</Header>
61-
<Box grow="Yes">
62-
<Box className={css.Content} direction="Column">
63-
<Scroll visibility="Hover" hideTrack size="300">
61+
<Box grow="Yes" style={{ width: '100%', minWidth: 0 }}>
62+
<Box
63+
grow="Yes"
64+
className={css.Content}
65+
direction="Column"
66+
style={{ width: '100%', minWidth: 0 }}
67+
>
68+
<Scroll visibility="Hover" hideTrack size="300" style={{ width: '100%' }}>
6469
{latestEventReaders.map((readerId) => {
6570
const name = getName(readerId);
6671
const avatarMxcUrl = room.getMember(readerId)?.getMxcAvatarUrl();
@@ -79,7 +84,7 @@ export const EventReaders = as<'div', EventReadersProps>(
7984
return (
8085
<MenuItem
8186
key={readerId}
82-
style={{ padding: `0 ${config.space.S200}` }}
87+
style={{ padding: `0 ${config.space.S200}`, width: '100%' }}
8388
radii="400"
8489
onClick={(event) => {
8590
openProfile(

src/app/components/member-tile/MemberTile.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const MemberTile = as<'button', MemberTileProps>(
2929
const name = getName(room, member, nicknames);
3030
const presence = useUserPresence(member.userId ?? '');
3131

32-
const avatarMxcUrl = member.getMxcAvatarUrl();
32+
const avatarMxcUrl = member.getMxcAvatarUrl() ?? mx.getUser(member.userId)?.avatarUrl;
3333
const avatarUrl = avatarMxcUrl
3434
? mx.mxcUrlToHttp(avatarMxcUrl, 100, 100, 'crop', undefined, false, useAuthentication)
3535
: undefined;

src/app/components/message/Reply.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import { useIgnoredUsers } from '$hooks/useIgnoredUsers';
2626
import { nicknamesAtom } from '$state/nicknames';
2727
import { useMatrixClient } from '$hooks/useMatrixClient';
2828
import { useMemberEventParser } from '$hooks/useMemberEventParser';
29+
import { useSetting } from '$state/hooks/settings';
30+
import { settingsAtom } from '$state/settings';
2931

3032
import { useMentionClickHandler } from '$hooks/useMentionClickHandler';
3133
import { useTranslation } from 'react-i18next';
@@ -139,6 +141,14 @@ export const Reply = as<'div', ReplyProps>(
139141
const nicknames = useAtomValue(nicknamesAtom);
140142
const useAuthentication = useMediaAuthentication();
141143
const settingsLinkBaseUrl = useSettingsLinkBaseUrl();
144+
const [incomingInlineImagesDefaultHeight] = useSetting(
145+
settingsAtom,
146+
'incomingInlineImagesDefaultHeight'
147+
);
148+
const [incomingInlineImagesMaxHeight] = useSetting(
149+
settingsAtom,
150+
'incomingInlineImagesMaxHeight'
151+
);
142152

143153
const fallbackBody = isRedacted ? <MessageDeletedContent /> : <MessageFailedContent />;
144154

@@ -190,6 +200,8 @@ export const Reply = as<'div', ReplyProps>(
190200
useAuthentication,
191201
nicknames,
192202
handleMentionClick: mentionClickHandler,
203+
incomingInlineImagesDefaultHeight,
204+
incomingInlineImagesMaxHeight,
193205
});
194206
bodyJSX = parse(sanitizedHtml, parserOpts) as JSX.Element;
195207
} else if (hasPlainTextReply) {

src/app/components/upload-card/UploadCardRenderer.tsx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ import { roomUploadAtomFamily } from '$state/room/roomInputDrafts';
3131
import { useObjectURL } from '$hooks/useObjectURL';
3232
import { useMediaConfig } from '$hooks/useMediaConfig';
3333
import { useSettingsLinkBaseUrl } from '$features/settings/useSettingsLinkBaseUrl';
34+
import { useSetting } from '$state/hooks/settings';
35+
import { settingsAtom } from '$state/settings';
3436
import { UploadCard, UploadCardError, UploadCardProgress } from './UploadCard';
3537
import * as css from './UploadCard.css';
3638
import { DescriptionEditor } from './UploadDescriptionEditor';
@@ -397,15 +399,31 @@ export function UploadCardRenderer({
397399
const spoilerClickHandler = useSpoilerClickHandler();
398400
const useAuthentication = useMediaAuthentication();
399401
const settingsLinkBaseUrl = useSettingsLinkBaseUrl();
402+
const [incomingInlineImagesDefaultHeight] = useSetting(
403+
settingsAtom,
404+
'incomingInlineImagesDefaultHeight'
405+
);
406+
const [incomingInlineImagesMaxHeight] = useSetting(settingsAtom, 'incomingInlineImagesMaxHeight');
400407
const htmlReactParserOptions = useMemo<HTMLReactParserOptions>(
401408
() =>
402409
getReactCustomHtmlParser(mx, roomId, {
403410
settingsLinkBaseUrl,
404411
linkifyOpts,
405412
useAuthentication,
406413
handleSpoilerClick: spoilerClickHandler,
414+
incomingInlineImagesDefaultHeight,
415+
incomingInlineImagesMaxHeight,
407416
}),
408-
[linkifyOpts, mx, roomId, settingsLinkBaseUrl, spoilerClickHandler, useAuthentication]
417+
[
418+
linkifyOpts,
419+
mx,
420+
roomId,
421+
settingsLinkBaseUrl,
422+
spoilerClickHandler,
423+
useAuthentication,
424+
incomingInlineImagesDefaultHeight,
425+
incomingInlineImagesMaxHeight,
426+
]
409427
);
410428
return (
411429
<UploadCard

0 commit comments

Comments
 (0)