Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/add_the_option_to_remove_the_fallback_from_pmps.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
default: minor
---

# Add the option to remove the fallback from PMPs
12 changes: 6 additions & 6 deletions src/app/features/room/RoomInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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>();

Expand Down Expand Up @@ -1100,7 +1101,8 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
eventId,
mMentions,
linkPreviews,
rawPmp
rawPmp,
pmpNoFallback
);

await mx.sendMessage(roomId, content as RoomMessageEventContent);
Expand Down Expand Up @@ -1359,12 +1361,9 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
}
if (perMessageProfile) {
content[prefix.MATRIX_UNSTABLE_PER_MESSAGE_PROFILE_PROPERTY_NAME] =
convertPerMessageProfileToBeeperFormat(
perMessageProfile,
perMessageProfile.displayname.trim() !== ''
);
convertPerMessageProfileToBeeperFormat(perMessageProfile, !pmpNoFallback);

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}: `;

Expand Down Expand Up @@ -1513,6 +1512,7 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
silentReply,
pmpProxyingEnable,
pmpLatchingEnable,
pmpNoFallback,
pluralkitProxyMessageHandler,
scheduledTime,
editingScheduledDelayId,
Expand Down
5 changes: 3 additions & 2 deletions src/app/features/room/buildReplacementContent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand All @@ -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;
Expand Down
6 changes: 4 additions & 2 deletions src/app/features/room/message/MessageEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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] =
Expand Down Expand Up @@ -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(() => {
Expand Down
172 changes: 101 additions & 71 deletions src/app/features/settings/Persona/PKCompat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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>
</>
);
}
1 change: 1 addition & 0 deletions src/app/features/settings/settingsLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
],
Expand Down
2 changes: 2 additions & 0 deletions src/app/state/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ export interface Settings {
pmpProxying: boolean;
pmpLatching: boolean;
pmpPicker: boolean;
pmpNoFallback: boolean;
mentionInReplies: boolean;
profileChangePropagation: ProfileChangePropagation;
showPersonaSetting: boolean;
Expand Down Expand Up @@ -424,6 +425,7 @@ export const defaultSettings: Settings = {
pmpProxying: false,
pmpLatching: false,
pmpPicker: false,
pmpNoFallback: false,
mentionInReplies: true,
profileChangePropagation: 'unchanged',
showPersonaSetting: false,
Expand Down
Loading