Skip to content

Commit 438c71f

Browse files
authored
Fix myroomnick and cosmetics settings not updating (#805)
<!-- 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. --> Fix myroomnick and cosmetics settings not updating Fixes #787 #### Type of change - [x] Bug fix (non-breaking change which fixes an issue) - [ ] 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: - [ ] My code follows the style guidelines of this project - [ ] 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 - [ ] My changes generate no new warnings ### AI disclosure: - [ ] 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. -->
2 parents b868f1d + 4e18c3c commit 438c71f

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

.changeset/fix-myroomnick.md

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 `/myroomnick` and room cosmetics display name not updating name.

src/app/hooks/useCommands.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,19 @@ export const useCommands = (mx: MatrixClient, room: Room): CommandRecord => {
497497
?.getStateEvents(EventType.RoomMember, mx.getSafeUserId());
498498
const content = mEvent?.getContent<RoomMemberEventContent>();
499499
if (!content) return;
500-
await mx.sendStateEvent(room.roomId, EventType.RoomMember, content, mx.getSafeUserId());
500+
const updatedContent: RoomMemberEventContent = { ...content };
501+
const withDisplay = updatedContent as RoomMemberEventContent & { displayname?: string };
502+
if (nick == null || nick === '') {
503+
delete withDisplay.displayname;
504+
} else {
505+
withDisplay.displayname = nick;
506+
}
507+
await mx.sendStateEvent(
508+
room.roomId,
509+
EventType.RoomMember,
510+
updatedContent,
511+
mx.getSafeUserId()
512+
);
501513
},
502514
},
503515
[Command.AddPerMessageProfileToAccount]: {

0 commit comments

Comments
 (0)