mirror of
https://github.com/SableClient/Sable.git
synced 2026-12-04 15:52:24 -08:00
Add the option to remove the fallback from PMPs
This commit is contained in:
1 parent
a9ac09e56a
commit
d4a20587d8
7 files changed
+121
-77
No files matched your search
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default: minor
|
||||
---
|
||||
|
||||
# Add the option to remove the fallback from PMPs
|
||||
@@ -341,6 +341,7 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
|
||||
const [pmpProxyingEnable] = useSetting(settingsAtom, 'pmpProxying');
|
||||
const [pmpLatchingEnable] = useSetting(settingsAtom, 'pmpLatching');
|
||||
const [pmpPickerEnable] = useSetting(settingsAtom, 'pmpPicker');
|
||||
const [pmpNoFallback] = useSetting(settingsAtom, 'pmpNoFallback');
|
||||
|
||||
const [latchedPersona, setLatchedPersona] = useState<PerMessageProfileMsc4461>();
|
||||
|
||||
@@ -1100,7 +1101,8 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
|
||||
eventId,
|
||||
mMentions,
|
||||
linkPreviews,
|
||||
rawPmp
|
||||
rawPmp,
|
||||
pmpNoFallback
|
||||
);
|
||||
|
||||
await mx.sendMessage(roomId, content as RoomMessageEventContent);
|
||||
@@ -1364,7 +1366,7 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
|
||||
perMessageProfile.displayname.trim() !== ''
|
||||
);
|
||||
|
||||
if (perMessageProfile.displayname.trim() !== '') {
|
||||
if (!pmpNoFallback && perMessageProfile.displayname.trim() !== '') {
|
||||
// if a per-message profile is used, it must per spec include a fallback
|
||||
const pmpPrefix = `${perMessageProfile.displayname}: `;
|
||||
|
||||
@@ -1513,6 +1515,7 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
|
||||
silentReply,
|
||||
pmpProxyingEnable,
|
||||
pmpLatchingEnable,
|
||||
pmpNoFallback,
|
||||
pluralkitProxyMessageHandler,
|
||||
scheduledTime,
|
||||
editingScheduledDelayId,
|
||||
|
||||
@@ -17,7 +17,8 @@ export function buildReplacementContent(
|
||||
eventId: string,
|
||||
mMentions: IMentions,
|
||||
linkPreviews: { matched_url: string }[],
|
||||
perMessageProfile: unknown
|
||||
perMessageProfile: unknown,
|
||||
pmpNoFallback: boolean
|
||||
): IContent {
|
||||
const pmpDisplayname =
|
||||
perMessageProfile !== null &&
|
||||
@@ -31,7 +32,7 @@ export function buildReplacementContent(
|
||||
let adjustedPlainText = plainText;
|
||||
let adjustedCustomHtml = customHtml;
|
||||
|
||||
if (pmpDisplayname) {
|
||||
if (!pmpNoFallback && pmpDisplayname) {
|
||||
const bodyPrefix = `${pmpDisplayname}: `;
|
||||
if (!adjustedPlainText.startsWith(bodyPrefix))
|
||||
adjustedPlainText = bodyPrefix + adjustedPlainText;
|
||||
|
||||
@@ -126,6 +126,7 @@ export const MessageEditor = as<'div', MessageEditorProps>(
|
||||
const nicknames = useAtomValue(nicknamesAtom);
|
||||
const editor = useEditor();
|
||||
const [enterForNewline] = useSetting(settingsAtom, 'enterForNewline');
|
||||
const [pmpNoFallback] = useSetting(settingsAtom, 'pmpNoFallback');
|
||||
const isComposing = useComposingCheck();
|
||||
|
||||
const [autocompleteQuery, setAutocompleteQuery] =
|
||||
@@ -292,11 +293,12 @@ export const MessageEditor = as<'div', MessageEditorProps>(
|
||||
eventId,
|
||||
mMentions,
|
||||
linkPreviews,
|
||||
rawPmp
|
||||
rawPmp,
|
||||
pmpNoFallback
|
||||
);
|
||||
|
||||
return mx.sendMessage(roomId, content as RoomMessageEventContent);
|
||||
}, [mx, editor, roomId, mEvent, getPrevBodyAndFormattedBody, room])
|
||||
}, [mx, editor, roomId, mEvent, getPrevBodyAndFormattedBody, room, pmpNoFallback])
|
||||
);
|
||||
|
||||
const handleSave = useCallback(() => {
|
||||
|
||||
@@ -8,78 +8,108 @@ export function PKCompatSettings() {
|
||||
const [usePKCompat, setUsePKCompat] = useSetting(settingsAtom, 'pkCompat');
|
||||
const [usePmpProxying, setUsePmpProxying] = useSetting(settingsAtom, 'pmpProxying');
|
||||
const [usePmpLatching, setUsePmpLatching] = useSetting(settingsAtom, 'pmpLatching');
|
||||
const [usePmpNoFallback, setUsePmpNoFallback] = useSetting(settingsAtom, 'pmpNoFallback');
|
||||
|
||||
return (
|
||||
<Box direction="Column" gap="100">
|
||||
<Text size="L400">Limited Compatibility with PluralKit-like functions</Text>
|
||||
<SequenceCard
|
||||
className={SequenceCardStyle}
|
||||
variant="SurfaceVariant"
|
||||
direction="Column"
|
||||
gap="100"
|
||||
>
|
||||
<SettingTile
|
||||
focusId="enable-pk-commands"
|
||||
title="Enable PK commands"
|
||||
description="If enabled, it will enable a few pk style commands, currently verry limited"
|
||||
after={
|
||||
<Switch
|
||||
variant="Primary"
|
||||
value={usePKCompat}
|
||||
onChange={setUsePKCompat}
|
||||
title={usePKCompat ? 'disable pk; commands' : 'enable pk; commands'}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
</SequenceCard>
|
||||
<SequenceCard
|
||||
className={SequenceCardStyle}
|
||||
variant="SurfaceVariant"
|
||||
direction="Column"
|
||||
gap="100"
|
||||
>
|
||||
<SettingTile
|
||||
focusId="enable-pk-shorthands"
|
||||
title="Enable Shorthands"
|
||||
description="If enabled, you can use shorthands to use a Persona for one message only (eg. '✨:test')"
|
||||
after={
|
||||
<Switch
|
||||
variant="Primary"
|
||||
value={usePmpProxying}
|
||||
onChange={setUsePmpProxying}
|
||||
title={
|
||||
usePmpProxying
|
||||
? 'disable checking typed messages for shorthands'
|
||||
: 'enable checking typed messages for shorthands'
|
||||
}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
</SequenceCard>
|
||||
<SequenceCard
|
||||
className={SequenceCardStyle}
|
||||
variant="SurfaceVariant"
|
||||
direction="Column"
|
||||
gap="100"
|
||||
>
|
||||
<SettingTile
|
||||
focusId="enable-pk-latching"
|
||||
title="Enable Shorthand Latching"
|
||||
description="If enabled, you change a room's persona when you use a shorthand."
|
||||
after={
|
||||
<Switch
|
||||
variant="Primary"
|
||||
value={usePmpLatching}
|
||||
onChange={setUsePmpLatching}
|
||||
title={
|
||||
usePmpLatching
|
||||
? 'disable latching when using a shorthand'
|
||||
: 'enable latching when using a shorthand'
|
||||
}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
</SequenceCard>
|
||||
</Box>
|
||||
<>
|
||||
<Box direction="Column" gap="100">
|
||||
<Text size="L400">Limited Compatibility with PluralKit-like functions</Text>
|
||||
<SequenceCard
|
||||
className={SequenceCardStyle}
|
||||
variant="SurfaceVariant"
|
||||
direction="Column"
|
||||
gap="100"
|
||||
>
|
||||
<SettingTile
|
||||
focusId="enable-pk-commands"
|
||||
title="Enable PK commands"
|
||||
description="If enabled, it will enable a few pk style commands, currently verry limited"
|
||||
after={
|
||||
<Switch
|
||||
variant="Primary"
|
||||
value={usePKCompat}
|
||||
onChange={setUsePKCompat}
|
||||
title={usePKCompat ? 'disable pk; commands' : 'enable pk; commands'}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
</SequenceCard>
|
||||
<SequenceCard
|
||||
className={SequenceCardStyle}
|
||||
variant="SurfaceVariant"
|
||||
direction="Column"
|
||||
gap="100"
|
||||
>
|
||||
<SettingTile
|
||||
focusId="enable-pk-shorthands"
|
||||
title="Enable Shorthands"
|
||||
description="If enabled, you can use shorthands to use a Persona for one message only (eg. '✨:test')"
|
||||
after={
|
||||
<Switch
|
||||
variant="Primary"
|
||||
value={usePmpProxying}
|
||||
onChange={setUsePmpProxying}
|
||||
title={
|
||||
usePmpProxying
|
||||
? 'disable checking typed messages for shorthands'
|
||||
: 'enable checking typed messages for shorthands'
|
||||
}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
</SequenceCard>
|
||||
<SequenceCard
|
||||
className={SequenceCardStyle}
|
||||
variant="SurfaceVariant"
|
||||
direction="Column"
|
||||
gap="100"
|
||||
>
|
||||
<SettingTile
|
||||
focusId="enable-pk-latching"
|
||||
title="Enable Shorthand Latching"
|
||||
description="If enabled, you change a room's persona when you use a shorthand."
|
||||
after={
|
||||
<Switch
|
||||
variant="Primary"
|
||||
value={usePmpLatching}
|
||||
onChange={setUsePmpLatching}
|
||||
title={
|
||||
usePmpLatching
|
||||
? 'disable latching when using a shorthand'
|
||||
: 'enable latching when using a shorthand'
|
||||
}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
</SequenceCard>
|
||||
</Box>
|
||||
<Box direction="Column" gap="100">
|
||||
<Text size="L400">General Behavior</Text>
|
||||
<SequenceCard
|
||||
className={SequenceCardStyle}
|
||||
variant="SurfaceVariant"
|
||||
direction="Column"
|
||||
gap="100"
|
||||
>
|
||||
<SettingTile
|
||||
focusId="prevent-sending-pmp-fallback"
|
||||
title="Prevent sending Persona fallback"
|
||||
description="If enabled, your messages will not include a prefix with your name to show clients that do not support Personas."
|
||||
after={
|
||||
<Switch
|
||||
variant="Primary"
|
||||
value={usePmpNoFallback}
|
||||
onChange={setUsePmpNoFallback}
|
||||
title={
|
||||
usePmpNoFallback
|
||||
? 'do not prevent fallbacks when sending a persona attached message'
|
||||
: 'prevent fallbacks when sending a persona attached message'
|
||||
}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
</SequenceCard>
|
||||
</Box>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -108,6 +108,7 @@ export const settingsLinkFocusIdsBySection: Record<SettingsSectionId, readonly s
|
||||
'enable-pk-commands',
|
||||
'enable-pk-shorthands',
|
||||
'enable-pk-latching',
|
||||
'prevent-sending-pmp-fallback',
|
||||
'create-pmp',
|
||||
'enable-pmp-picker',
|
||||
],
|
||||
|
||||
@@ -243,6 +243,7 @@ export interface Settings {
|
||||
pmpProxying: boolean;
|
||||
pmpLatching: boolean;
|
||||
pmpPicker: boolean;
|
||||
pmpNoFallback: boolean;
|
||||
mentionInReplies: boolean;
|
||||
profileChangePropagation: ProfileChangePropagation;
|
||||
showPersonaSetting: boolean;
|
||||
@@ -424,6 +425,7 @@ export const defaultSettings: Settings = {
|
||||
pmpProxying: false,
|
||||
pmpLatching: false,
|
||||
pmpPicker: false,
|
||||
pmpNoFallback: false,
|
||||
mentionInReplies: true,
|
||||
profileChangePropagation: 'unchanged',
|
||||
showPersonaSetting: false,
|
||||
|
||||
Reference in new issue
Block a user