Skip to content

Commit

Permalink
Fix a crash when opening v11 rooms. (#7635)
Browse files Browse the repository at this point in the history
  • Loading branch information
pixlwave authored Aug 4, 2023
1 parent 04c7a02 commit d3e64c1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 21 deletions.
46 changes: 25 additions & 21 deletions Riot/Modules/MatrixKit/Utils/EventFormatter/MXKEventFormatter.m
Original file line number Diff line number Diff line change
Expand Up @@ -833,35 +833,39 @@ - (NSAttributedString *)attributedStringFromEvent:(MXEvent*)event
NSString *creatorId;
MXJSONModelSetString(creatorId, event.content[@"creator"]);

if (creatorId)
if (!creatorId)
{
if ([creatorId isEqualToString:mxSession.myUserId])
// Room version 11 removes `creator` in favour of `sender`.
// https://github.com/matrix-org/matrix-spec-proposals/pull/2175
creatorId = event.sender;
}

if ([creatorId isEqualToString:mxSession.myUserId])
{
if (isRoomDirect)
{
if (isRoomDirect)
{
displayText = [VectorL10n noticeRoomCreatedByYouForDm];
}
else
{
displayText = [VectorL10n noticeRoomCreatedByYou];
}
displayText = [VectorL10n noticeRoomCreatedByYouForDm];
}
else
{
if (isRoomDirect)
{
displayText = [VectorL10n noticeRoomCreatedForDm:(roomState ? [roomState.members memberName:creatorId] : creatorId)];
}
else
{
displayText = [VectorL10n noticeRoomCreated:(roomState ? [roomState.members memberName:creatorId] : creatorId)];
}
displayText = [VectorL10n noticeRoomCreatedByYou];
}
// Append redacted info if any
if (redactedInfo)
}
else
{
if (isRoomDirect)
{
displayText = [NSString stringWithFormat:@"%@ %@", displayText, redactedInfo];
displayText = [VectorL10n noticeRoomCreatedForDm:(roomState ? [roomState.members memberName:creatorId] : creatorId)];
}
else
{
displayText = [VectorL10n noticeRoomCreated:(roomState ? [roomState.members memberName:creatorId] : creatorId)];
}
}
// Append redacted info if any
if (redactedInfo)
{
displayText = [NSString stringWithFormat:@"%@ %@", displayText, redactedInfo];
}
break;
}
Expand Down
1 change: 1 addition & 0 deletions changelog.d/7633.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a crash when opening v11 rooms.

0 comments on commit d3e64c1

Please sign in to comment.