Merge remote-tracking branch 'fork-new/dev' into feat/allow-setting-pmp
This commit is contained in:
21 files changed
+338
-48
No files matched your search
@@ -1,5 +0,0 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
Fix messages with body empty but formatted body filled rendering as empty.
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
Fix emoticon autocomplete not respecting character threshold setting.
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
Fix images without explicit dimensions not appearing.
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
Fix Mac OS to macOS in the the devices tab
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
Hide presence badge in members list for users without homeserver support, mimicking room profile apperance.
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
# Improved voice message recording UI, it should now feel a lot more integrated.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
Added a toggle to notifications to disable full message mention highlighting.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default: minor
|
||||
---
|
||||
|
||||
Added a setting to Appearance that attempts to convert text in names like (it/its) into a pronoun pill, enlabed by default.
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
Add opt-in Sentry crash reporting with a consent banner.
|
||||
+1
-1
@@ -1 +1 @@
|
||||
* @7w1 @Just-Insane @hazre
|
||||
* @7w1 @hazre
|
||||
@@ -1,5 +1,17 @@
|
||||
# Sable Client Changelog
|
||||
|
||||
## 1.9.3 (2026-03-17)
|
||||
|
||||
### Fixes
|
||||
|
||||
* Fix autocomplete Enter & Tab key always selecting the first item and the first item not being highlighted on open. ([#310](https://github.com/SableClient/Sable/pull/310) by @Just-Insane)
|
||||
* Fix messages with body empty but formatted body filled rendering as empty. ([#337](https://github.com/SableClient/Sable/pull/337) by @7w1)
|
||||
* Fix emoticon autocomplete not respecting character threshold setting. ([#337](https://github.com/SableClient/Sable/pull/337) by @7w1)
|
||||
* Fix images without explicit dimensions not appearing. ([#338](https://github.com/SableClient/Sable/pull/338) by @7w1)
|
||||
* Fix Mac OS to macOS in the the devices tab ([#328](https://github.com/SableClient/Sable/pull/328) by @DidiDidi129)
|
||||
* Improved voice message recording UI, it should now feel a lot more integrated. ([#311](https://github.com/SableClient/Sable/pull/311) by @hazre)
|
||||
* Add opt-in Sentry crash reporting with a consent banner. ([#333](https://github.com/SableClient/Sable/pull/333) by @Just-Insane)
|
||||
|
||||
## 1.9.2 (2026-03-17)
|
||||
|
||||
### Fixes
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "sable",
|
||||
"version": "1.9.2",
|
||||
"version": "1.9.3",
|
||||
"description": "An almost stable Matrix client",
|
||||
"type": "module",
|
||||
"packageManager": "[email protected]+sha512.a706938f0e89ac1456b6563eab4edf1d1faf3368d1191fc5c59790e96dc918e4456ab2e67d613de1043d2e8c81f87303e6b40d4ffeca9df15ef1ad567348f2be",
|
||||
|
||||
@@ -0,0 +1,193 @@
|
||||
import { type ReactNode } from 'react';
|
||||
import { describe, it, expect, vi } from 'vitest';
|
||||
import { render, act } from '@testing-library/react';
|
||||
import {
|
||||
AutocompleteMenu,
|
||||
AUTOCOMPLETE_NAVIGATE_EVENT,
|
||||
type AutocompleteNavigateDetail,
|
||||
} from './AutocompleteMenu';
|
||||
|
||||
// ── Mocks ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
vi.mock('focus-trap-react', () => ({
|
||||
default: ({ children }: { children: ReactNode }) => <>{children}</>,
|
||||
}));
|
||||
|
||||
vi.mock('folds', () => ({
|
||||
Header: ({ children }: { children: ReactNode }) => <div>{children}</div>,
|
||||
Menu: ({ children }: { children: ReactNode }) => <div>{children}</div>,
|
||||
Scroll: ({ children, onKeyDown }: { children: ReactNode; onKeyDown?: unknown }) => (
|
||||
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
||||
<div onKeyDown={onKeyDown as React.KeyboardEventHandler}>{children}</div>
|
||||
),
|
||||
config: { space: { S200: '8px' } },
|
||||
Icons: {},
|
||||
}));
|
||||
|
||||
vi.mock('$utils/keyboard', () => ({
|
||||
preventScrollWithArrowKey: vi.fn(),
|
||||
stopPropagation: vi.fn(() => true),
|
||||
}));
|
||||
|
||||
vi.mock('$hooks/useAlive', () => ({
|
||||
useAlive: () => () => true,
|
||||
}));
|
||||
|
||||
// ── Helpers ───────────────────────────────────────────────────────────────────
|
||||
|
||||
function dispatchNavigate(container: HTMLElement, direction: 1 | -1) {
|
||||
const menu = container.querySelector('[data-autocomplete-menu]');
|
||||
if (!menu) throw new Error('data-autocomplete-menu element not found');
|
||||
menu.dispatchEvent(
|
||||
new CustomEvent<AutocompleteNavigateDetail>(AUTOCOMPLETE_NAVIGATE_EVENT, {
|
||||
bubbles: true,
|
||||
detail: { direction },
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
function renderMenu(children: ReactNode) {
|
||||
return render(
|
||||
<AutocompleteMenu headerContent={<span>header</span>} requestClose={() => {}}>
|
||||
{children}
|
||||
</AutocompleteMenu>
|
||||
);
|
||||
}
|
||||
|
||||
// ── Tests ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
describe('AutocompleteMenu — data-selected stamping', () => {
|
||||
it('stamps the first button with data-selected="true" on initial render', () => {
|
||||
const { container } = renderMenu(
|
||||
<>
|
||||
<button type="button">Item 0</button>
|
||||
<button type="button">Item 1</button>
|
||||
<button type="button">Item 2</button>
|
||||
</>
|
||||
);
|
||||
|
||||
const buttons = container.querySelectorAll<HTMLButtonElement>('button');
|
||||
expect(buttons[0].getAttribute('data-selected')).toBe('true');
|
||||
expect(buttons[1].getAttribute('data-selected')).toBe('false');
|
||||
expect(buttons[2].getAttribute('data-selected')).toBe('false');
|
||||
});
|
||||
|
||||
it('stamps buttons when children load after initial render (async results)', async () => {
|
||||
// Start with no children (empty search, buttons not yet present)
|
||||
const { container, rerender } = renderMenu(null);
|
||||
|
||||
// Simulate async search results arriving
|
||||
await act(async () => {
|
||||
rerender(
|
||||
<AutocompleteMenu headerContent={<span>header</span>} requestClose={() => {}}>
|
||||
<button type="button">Result A</button>
|
||||
<button type="button">Result B</button>
|
||||
</AutocompleteMenu>
|
||||
);
|
||||
});
|
||||
|
||||
const buttons = container.querySelectorAll<HTMLButtonElement>('button');
|
||||
expect(buttons).toHaveLength(2);
|
||||
// First button must be marked selected — this was the bug: with the old
|
||||
// [selectedIndex] dep array the effect didn't re-run when buttons appeared.
|
||||
expect(buttons[0].getAttribute('data-selected')).toBe('true');
|
||||
expect(buttons[1].getAttribute('data-selected')).toBe('false');
|
||||
});
|
||||
|
||||
it('resets selection to the first button when the item list changes', async () => {
|
||||
const { container } = renderMenu(
|
||||
<>
|
||||
<button type="button">Item 0</button>
|
||||
<button type="button">Item 1</button>
|
||||
</>
|
||||
);
|
||||
|
||||
// Navigate to the second item
|
||||
act(() => dispatchNavigate(container, 1));
|
||||
|
||||
const before = container.querySelectorAll<HTMLButtonElement>('button');
|
||||
expect(before[1].getAttribute('data-selected')).toBe('true');
|
||||
|
||||
// Re-render with a completely different set of buttons (new search results)
|
||||
await act(async () => {
|
||||
render(
|
||||
<AutocompleteMenu headerContent={<span>header</span>} requestClose={() => {}}>
|
||||
<button type="button">New A</button>
|
||||
<button type="button">New B</button>
|
||||
<button type="button">New C</button>
|
||||
</AutocompleteMenu>,
|
||||
{ container: container.firstElementChild?.parentElement ?? document.body }
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('AutocompleteMenu — keyboard navigation', () => {
|
||||
it('moves selection forward with direction +1', () => {
|
||||
const { container } = renderMenu(
|
||||
<>
|
||||
<button type="button">Item 0</button>
|
||||
<button type="button">Item 1</button>
|
||||
<button type="button">Item 2</button>
|
||||
</>
|
||||
);
|
||||
|
||||
act(() => dispatchNavigate(container, 1));
|
||||
|
||||
const buttons = container.querySelectorAll<HTMLButtonElement>('button');
|
||||
expect(buttons[0].getAttribute('data-selected')).toBe('false');
|
||||
expect(buttons[1].getAttribute('data-selected')).toBe('true');
|
||||
expect(buttons[2].getAttribute('data-selected')).toBe('false');
|
||||
});
|
||||
|
||||
it('moves selection backward with direction -1', () => {
|
||||
const { container } = renderMenu(
|
||||
<>
|
||||
<button type="button">Item 0</button>
|
||||
<button type="button">Item 1</button>
|
||||
<button type="button">Item 2</button>
|
||||
</>
|
||||
);
|
||||
|
||||
// Go to last item first
|
||||
act(() => dispatchNavigate(container, 1));
|
||||
act(() => dispatchNavigate(container, 1));
|
||||
|
||||
act(() => dispatchNavigate(container, -1));
|
||||
|
||||
const buttons = container.querySelectorAll<HTMLButtonElement>('button');
|
||||
expect(buttons[0].getAttribute('data-selected')).toBe('false');
|
||||
expect(buttons[1].getAttribute('data-selected')).toBe('true');
|
||||
expect(buttons[2].getAttribute('data-selected')).toBe('false');
|
||||
});
|
||||
|
||||
it('clamps selection at the first item when navigating backward at index 0', () => {
|
||||
const { container } = renderMenu(
|
||||
<>
|
||||
<button type="button">Item 0</button>
|
||||
<button type="button">Item 1</button>
|
||||
</>
|
||||
);
|
||||
|
||||
act(() => dispatchNavigate(container, -1));
|
||||
|
||||
const buttons = container.querySelectorAll<HTMLButtonElement>('button');
|
||||
expect(buttons[0].getAttribute('data-selected')).toBe('true');
|
||||
});
|
||||
|
||||
it('clamps selection at the last item when navigating forward past the end', () => {
|
||||
const { container } = renderMenu(
|
||||
<>
|
||||
<button type="button">Item 0</button>
|
||||
<button type="button">Item 1</button>
|
||||
</>
|
||||
);
|
||||
|
||||
act(() => dispatchNavigate(container, 1));
|
||||
act(() => dispatchNavigate(container, 1)); // attempt to go past the end
|
||||
|
||||
const buttons = container.querySelectorAll<HTMLButtonElement>('button');
|
||||
expect(buttons[0].getAttribute('data-selected')).toBe('false');
|
||||
expect(buttons[1].getAttribute('data-selected')).toBe('true');
|
||||
});
|
||||
});
|
||||
@@ -28,7 +28,12 @@ export function AutocompleteMenu({ headerContent, requestClose, children }: Auto
|
||||
}
|
||||
};
|
||||
|
||||
// Sync data-selected to DOM; reset to index 0 when the item list changes
|
||||
// Sync data-selected to DOM; reset to index 0 when the item list changes.
|
||||
// No dep array — runs after every render so newly-loaded buttons are stamped
|
||||
// immediately (buttons arrive async when search results load).
|
||||
// setSelectedIndex is a stable React setter; the conditional call never
|
||||
// triggers an infinite update chain (it only fires when button count changes).
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
useLayoutEffect(() => {
|
||||
const buttons = Array.from(
|
||||
itemsRef.current?.querySelectorAll<HTMLButtonElement>('button') ?? []
|
||||
@@ -46,7 +51,7 @@ export function AutocompleteMenu({ headerContent, requestClose, children }: Auto
|
||||
buttons.forEach((btn, i) => {
|
||||
btn.setAttribute('data-selected', String(i === safeIdx));
|
||||
});
|
||||
}, [selectedIndex]);
|
||||
});
|
||||
|
||||
// Listen for navigation events dispatched by the editor key handler
|
||||
useEffect(() => {
|
||||
|
||||
@@ -155,7 +155,11 @@ function MemberItem({
|
||||
}}
|
||||
>
|
||||
<AvatarPresence
|
||||
badge={presence && <PresenceBadge presence={presence.presence} size="200" />}
|
||||
badge={
|
||||
presence && presence.lastActiveTs !== 0 ? (
|
||||
<PresenceBadge presence={presence.presence} size="200" />
|
||||
) : undefined
|
||||
}
|
||||
>
|
||||
<Avatar size="300" radii="400">
|
||||
<UserAvatar
|
||||
|
||||
@@ -842,9 +842,9 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
|
||||
return;
|
||||
}
|
||||
|
||||
if (isKeyHotkey('enter', evt) && !isComposing(evt)) {
|
||||
if ((isKeyHotkey('enter', evt) || isKeyHotkey('tab', evt)) && !isComposing(evt)) {
|
||||
const selectedItem =
|
||||
autocompleteMenu.querySelector<HTMLButtonElement>('button[data-selected]') ??
|
||||
autocompleteMenu.querySelector<HTMLButtonElement>('button[data-selected="true"]') ??
|
||||
autocompleteMenu.querySelector<HTMLButtonElement>('button');
|
||||
|
||||
if (selectedItem) {
|
||||
|
||||
@@ -79,7 +79,7 @@ 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 { filterPronounsByLanguage, getParsedPronouns } from '$utils/pronouns';
|
||||
import { useMentionClickHandler } from '$hooks/useMentionClickHandler';
|
||||
import {
|
||||
addStickerToDefaultPack,
|
||||
@@ -407,6 +407,8 @@ function MessageInternal(
|
||||
*/
|
||||
const pronouns = parsedPMPContent?.pronouns ?? profile.pronouns;
|
||||
|
||||
const [highlightMentions] = useSetting(settingsAtom, 'highlightMentions');
|
||||
|
||||
// Avatars
|
||||
// Prefer the room-scoped member avatar (m.room.member) over the global profile
|
||||
// avatar so per-room avatar overrides are respected in the timeline.
|
||||
@@ -416,11 +418,6 @@ function MessageInternal(
|
||||
return mxc ? mxcUrlToHttp(mx, mxc, useAuthentication, 48, 48, 'crop') : undefined;
|
||||
}, [pmp, collapse, profile.avatarUrl, senderId, mx, room, useAuthentication]);
|
||||
|
||||
const displayName = useMemo(
|
||||
() => pmp?.displayname || senderDisplayName,
|
||||
[pmp, senderDisplayName]
|
||||
);
|
||||
|
||||
const cachedAvatar = useBlobCache(avatarUrl ?? undefined);
|
||||
|
||||
// UI State
|
||||
@@ -449,8 +446,32 @@ function MessageInternal(
|
||||
|
||||
const [mobileOptionsOpen, setMobileOptionsOpen] = useState(false);
|
||||
const optionsRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
const [showPronouns] = useSetting(settingsAtom, 'showPronouns');
|
||||
const [parsePronouns] = useSetting(settingsAtom, 'parsePronouns');
|
||||
|
||||
const [useRightBubbles] = useSetting(settingsAtom, 'useRightBubbles');
|
||||
const { cleanedDisplayName, inlinePronoun } = useMemo(() => {
|
||||
const rawName = pmp?.displayname || senderDisplayName || '';
|
||||
return getParsedPronouns(rawName, parsePronouns);
|
||||
}, [pmp, senderDisplayName, parsePronouns]);
|
||||
|
||||
const mergedPronouns = useMemo(() => {
|
||||
const existing = profile.pronouns ? [...profile.pronouns] : [];
|
||||
|
||||
if (inlinePronoun) {
|
||||
const isDupe = existing.some((p) => p.summary?.toLowerCase() === inlinePronoun);
|
||||
|
||||
if (!isDupe) {
|
||||
existing.push({
|
||||
summary: inlinePronoun,
|
||||
language: 'en',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return existing;
|
||||
}, [profile.pronouns, inlinePronoun]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!mobileOptionsOpen) return undefined;
|
||||
@@ -483,7 +504,7 @@ function MessageInternal(
|
||||
onClick={onUsernameClick}
|
||||
>
|
||||
<Text as="span" size={messageLayout === MessageLayout.Bubble ? 'T300' : 'T400'} truncate>
|
||||
<UsernameBold>{displayName}</UsernameBold>
|
||||
<UsernameBold>{cleanedDisplayName}</UsernameBold>
|
||||
</Text>
|
||||
</Username>
|
||||
{showPronouns && (
|
||||
@@ -526,7 +547,7 @@ function MessageInternal(
|
||||
<UserAvatar
|
||||
userId={senderId}
|
||||
src={cachedAvatar}
|
||||
alt={displayName}
|
||||
alt={cleanedDisplayName}
|
||||
renderFallback={() => <Icon size="200" src={Icons.User} filled />}
|
||||
/>
|
||||
</Avatar>
|
||||
@@ -751,7 +772,7 @@ function MessageInternal(
|
||||
space={messageSpacing}
|
||||
collapse={collapse}
|
||||
highlight={highlight}
|
||||
notifyHighlight={notifyHighlight}
|
||||
notifyHighlight={highlightMentions ? notifyHighlight : undefined}
|
||||
selected={!!menuAnchor || !!emojiBoardAnchor}
|
||||
{...props}
|
||||
{...hoverProps}
|
||||
@@ -1002,7 +1023,7 @@ function MessageInternal(
|
||||
autoFocus
|
||||
value={nickDraft}
|
||||
onChange={(e) => setNickDraft(e.target.value)}
|
||||
placeholder={displayName}
|
||||
placeholder={cleanedDisplayName}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter') {
|
||||
setNickname(senderId, nickDraft || undefined, mx);
|
||||
@@ -1176,6 +1197,7 @@ export const Event = as<'div', EventProps>(
|
||||
|
||||
const [menuAnchor, setMenuAnchor] = useState<RectCords>();
|
||||
const [mobileOptionsOpen, setMobileOptionsOpen] = useState(false);
|
||||
const [highlightMentions] = useSetting(settingsAtom, 'highlightMentions');
|
||||
|
||||
const handleContextMenu: MouseEventHandler<HTMLDivElement> = (evt) => {
|
||||
if (mobileOrTablet()) {
|
||||
@@ -1252,7 +1274,7 @@ export const Event = as<'div', EventProps>(
|
||||
space={messageSpacing}
|
||||
autoCollapse
|
||||
highlight={highlight}
|
||||
notifyHighlight={notifyHighlight}
|
||||
notifyHighlight={highlightMentions ? notifyHighlight : undefined}
|
||||
selected={!!menuAnchor}
|
||||
{...props}
|
||||
{...hoverProps}
|
||||
|
||||
@@ -165,6 +165,7 @@ function IdentityCosmetics() {
|
||||
'legacyUsernameColor'
|
||||
);
|
||||
const [showPronouns, setShowPronouns] = useSetting(settingsAtom, 'showPronouns');
|
||||
const [parsePronouns, setParsePronouns] = useSetting(settingsAtom, 'parsePronouns');
|
||||
const [renderGlobalColors, setRenderGlobalColors] = useSetting(
|
||||
settingsAtom,
|
||||
'renderGlobalNameColors'
|
||||
@@ -196,6 +197,13 @@ function IdentityCosmetics() {
|
||||
after={<Switch variant="Primary" value={showPronouns} onChange={setShowPronouns} />}
|
||||
/>
|
||||
</SequenceCard>
|
||||
<SequenceCard className={SequenceCardStyle} variant="SurfaceVariant" direction="Column">
|
||||
<SettingTile
|
||||
title="Pronoun Pills for All"
|
||||
description="Attempts to convert pronouns in names into pills (e.g. [they/them] or (it/its) turns into a pill)."
|
||||
after={<Switch variant="Primary" value={parsePronouns} onChange={setParsePronouns} />}
|
||||
/>
|
||||
</SequenceCard>
|
||||
<SequenceCard className={SequenceCardStyle} variant="SurfaceVariant" direction="Column">
|
||||
<SettingTile
|
||||
title="Render Global Username Colors"
|
||||
|
||||
@@ -193,6 +193,7 @@ export function SystemNotification() {
|
||||
settingsAtom,
|
||||
'faviconForMentionsOnly'
|
||||
);
|
||||
const [highlightMentions, setHighlightMentions] = useSetting(settingsAtom, 'highlightMentions');
|
||||
|
||||
// Describe what the current badge combo actually does so users aren't left guessing.
|
||||
const badgeBehaviourSummary = (): string => {
|
||||
@@ -400,6 +401,20 @@ export function SystemNotification() {
|
||||
after={<Switch variant="Primary" value={showPingCounts} onChange={setShowPingCounts} />}
|
||||
/>
|
||||
</SequenceCard>
|
||||
<SequenceCard
|
||||
className={SequenceCardStyle}
|
||||
variant="SurfaceVariant"
|
||||
direction="Column"
|
||||
gap="400"
|
||||
>
|
||||
<SettingTile
|
||||
title="Highlight Mentions"
|
||||
description="Highlight the full background message when it contains a mention/keyword."
|
||||
after={
|
||||
<Switch variant="Primary" value={highlightMentions} onChange={setHighlightMentions} />
|
||||
}
|
||||
/>
|
||||
</SequenceCard>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
@@ -71,6 +71,7 @@ export interface Settings {
|
||||
privacyBlurAvatars: boolean;
|
||||
privacyBlurEmotes: boolean;
|
||||
showPronouns: boolean;
|
||||
parsePronouns: boolean;
|
||||
renderGlobalNameColors: boolean;
|
||||
filterPronounsBasedOnLanguage?: boolean;
|
||||
filterPronounsLanguages?: string[];
|
||||
@@ -97,6 +98,7 @@ export interface Settings {
|
||||
saveStickerEmojiBandwidth: boolean;
|
||||
alwaysShowCallButton: boolean;
|
||||
faviconForMentionsOnly: boolean;
|
||||
highlightMentions: boolean;
|
||||
|
||||
// furry stuff
|
||||
renderAnimals: boolean;
|
||||
@@ -154,6 +156,7 @@ const defaultSettings: Settings = {
|
||||
privacyBlurAvatars: false,
|
||||
privacyBlurEmotes: false,
|
||||
showPronouns: true,
|
||||
parsePronouns: true,
|
||||
renderGlobalNameColors: true,
|
||||
renderRoomColors: true,
|
||||
renderRoomFonts: true,
|
||||
@@ -178,6 +181,7 @@ const defaultSettings: Settings = {
|
||||
saveStickerEmojiBandwidth: false,
|
||||
alwaysShowCallButton: false,
|
||||
faviconForMentionsOnly: false,
|
||||
highlightMentions: true,
|
||||
|
||||
// furry stuff
|
||||
renderAnimals: true,
|
||||
|
||||
@@ -73,3 +73,45 @@ export function filterPronounsByLanguage(
|
||||
|
||||
return filteredPronouns;
|
||||
}
|
||||
|
||||
const pronounParseCache = new Map<
|
||||
string,
|
||||
{ cleanedDisplayName: string; inlinePronoun: string | null }
|
||||
>();
|
||||
|
||||
export function getParsedPronouns(rawName: string, parseSetting: boolean) {
|
||||
if (!parseSetting || !rawName) {
|
||||
return { cleanedDisplayName: rawName, inlinePronoun: null };
|
||||
}
|
||||
|
||||
if (pronounParseCache.has(rawName)) {
|
||||
return pronounParseCache.get(rawName)!;
|
||||
}
|
||||
|
||||
// match text like (she/her) or [he/they/them] but not (hi)
|
||||
const regex = /[([]?([a-zA-Z]+\/[a-zA-Z]+(?:\/[a-zA-Z]+)?)[)\]]?/;
|
||||
const match = rawName.match(regex);
|
||||
|
||||
let result: { cleanedDisplayName: string; inlinePronoun: string | null } = {
|
||||
cleanedDisplayName: rawName,
|
||||
inlinePronoun: null,
|
||||
};
|
||||
|
||||
if (match) {
|
||||
let strippedName = rawName.replace(match[0], '').trim();
|
||||
if (!strippedName || strippedName === '') {
|
||||
strippedName = rawName;
|
||||
}
|
||||
result = {
|
||||
cleanedDisplayName: strippedName,
|
||||
inlinePronoun: match[1].toLowerCase().slice(0, 16),
|
||||
};
|
||||
}
|
||||
|
||||
if (pronounParseCache.size > 1000) {
|
||||
pronounParseCache.clear();
|
||||
}
|
||||
|
||||
pronounParseCache.set(rawName, result);
|
||||
return result;
|
||||
}
|
||||
Reference in new issue
Block a user