Skip to content

Commit d3e64c1

Browse files
authored
Fix a crash when opening v11 rooms. (#7635)
matrix-org/matrix-spec-proposals#2175
1 parent 04c7a02 commit d3e64c1

File tree

2 files changed

+26
-21
lines changed

2 files changed

+26
-21
lines changed

Riot/Modules/MatrixKit/Utils/EventFormatter/MXKEventFormatter.m

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -833,35 +833,39 @@ - (NSAttributedString *)attributedStringFromEvent:(MXEvent*)event
833833
NSString *creatorId;
834834
MXJSONModelSetString(creatorId, event.content[@"creator"]);
835835

836-
if (creatorId)
836+
if (!creatorId)
837837
{
838-
if ([creatorId isEqualToString:mxSession.myUserId])
838+
// Room version 11 removes `creator` in favour of `sender`.
839+
// https://github.com/matrix-org/matrix-spec-proposals/pull/2175
840+
creatorId = event.sender;
841+
}
842+
843+
if ([creatorId isEqualToString:mxSession.myUserId])
844+
{
845+
if (isRoomDirect)
839846
{
840-
if (isRoomDirect)
841-
{
842-
displayText = [VectorL10n noticeRoomCreatedByYouForDm];
843-
}
844-
else
845-
{
846-
displayText = [VectorL10n noticeRoomCreatedByYou];
847-
}
847+
displayText = [VectorL10n noticeRoomCreatedByYouForDm];
848848
}
849849
else
850850
{
851-
if (isRoomDirect)
852-
{
853-
displayText = [VectorL10n noticeRoomCreatedForDm:(roomState ? [roomState.members memberName:creatorId] : creatorId)];
854-
}
855-
else
856-
{
857-
displayText = [VectorL10n noticeRoomCreated:(roomState ? [roomState.members memberName:creatorId] : creatorId)];
858-
}
851+
displayText = [VectorL10n noticeRoomCreatedByYou];
859852
}
860-
// Append redacted info if any
861-
if (redactedInfo)
853+
}
854+
else
855+
{
856+
if (isRoomDirect)
862857
{
863-
displayText = [NSString stringWithFormat:@"%@ %@", displayText, redactedInfo];
858+
displayText = [VectorL10n noticeRoomCreatedForDm:(roomState ? [roomState.members memberName:creatorId] : creatorId)];
864859
}
860+
else
861+
{
862+
displayText = [VectorL10n noticeRoomCreated:(roomState ? [roomState.members memberName:creatorId] : creatorId)];
863+
}
864+
}
865+
// Append redacted info if any
866+
if (redactedInfo)
867+
{
868+
displayText = [NSString stringWithFormat:@"%@ %@", displayText, redactedInfo];
865869
}
866870
break;
867871
}

changelog.d/7633.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix a crash when opening v11 rooms.

0 commit comments

Comments
 (0)