Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Fix array checks & add some notes.
Browse files Browse the repository at this point in the history
  • Loading branch information
clokep committed Mar 3, 2023
1 parent e67067c commit 35df700
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/components/views/rooms/EditMessageComposer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,11 @@ function createEditContent(model: EditorModel, editedEvent: MatrixEvent): IConte

// Attach the *differential* mentions of any *newly* mentioned users / room.
const mentions: IMentions = {};
const userIds = editedEvent.getContent()["org.matrix.msc3952.mentions"]?.user_ids;
let prevUserMentions = [];
if (Array.isArray(userIds?.user_ids)) {
prevUserMentions = userIds.user_ids;
// TODO What if the edit doesn't have the mentions property?
const prevMentions = editedEvent.getContent()["org.matrix.msc3952.mentions"];
let prevUserMentions = prevMentions?.user_ids;
if (!Array.isArray(prevUserMentions)) {
prevUserMentions = [];
}
const newUserMentions = new Set<string>();
for (const part of model.parts) {
Expand Down
2 changes: 2 additions & 0 deletions src/components/views/rooms/SendMessageComposer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ export function attachMentions(
// event + any mentioned users in that event.
if (replyToEvent) {
userMentions.add(replyToEvent.sender.userId);
// TODO What do we do if the prely event *doeesn't* have this property?
// Try to fish out replies from the contents?
const userIds = replyToEvent.getContent()["org.matrix.msc3952.mentions"]?.user_ids;
if (Array.isArray(userIds)) {
userIds.forEach((userId) => userMentions.add(userId));
Expand Down

0 comments on commit 35df700

Please sign in to comment.