diff --git a/.changeset/fix_pmp_empty_displayname.md b/.changeset/fix_pmp_empty_displayname.md new file mode 100644 index 00000000..97e6e2d7 --- /dev/null +++ b/.changeset/fix_pmp_empty_displayname.md @@ -0,0 +1,5 @@ +--- +default: patch +--- + +fix the issue of empty displaynames of a persona, causing an empty fallback message, it will now ommit the fallback, if the name is empty or only consists of whitespace diff --git a/src/app/features/room/RoomInput.tsx b/src/app/features/room/RoomInput.tsx index fb0c1165..b9d2dbb6 100644 --- a/src/app/features/room/RoomInput.tsx +++ b/src/app/features/room/RoomInput.tsx @@ -770,10 +770,10 @@ export const RoomInput = forwardRef( if (perMessageProfile) { content['com.beeper.per_message_profile'] = convertPerMessageProfileToBeeperFormat( perMessageProfile, - perMessageProfile.name !== '' + perMessageProfile.name.trim() !== '' ); - if (perMessageProfile.name !== '') { + if (perMessageProfile.name.trim() !== '') { // if a per-message profile is used, it must per spec include a fallback const prefix = `${perMessageProfile.name}: `; diff --git a/src/app/hooks/usePerMessageProfile.ts b/src/app/hooks/usePerMessageProfile.ts index fa724b51..966db2af 100644 --- a/src/app/hooks/usePerMessageProfile.ts +++ b/src/app/hooks/usePerMessageProfile.ts @@ -73,7 +73,7 @@ export function convertPerMessageProfileToBeeperFormat( }; // delete empty fields // to-do maybe find a better way of doing it - if (!profile.name) delete beeperPMP.displayname; + if (!profile.name || profile?.name.trim().length === 0) delete beeperPMP.displayname; if (!profile.avatarUrl) delete beeperPMP.avatar_url; if (!profile.pronouns || profile.pronouns?.length === 0) delete beeperPMP['io.fsky.nyx.pronouns']; if (!has_fallback) delete beeperPMP.has_fallback;