[EventFormatter] Update room create event type processing when content has room predecessor info.

This commit is contained in:
SBiOSoftWhare 2018-08-07 11:23:03 +02:00
parent 62a443f6b0
commit eb9892704f

View file

@ -115,9 +115,20 @@ NSString *const kEventFormatterOnReRequestKeysLinkActionSeparator = @"/";
}
}
if (event.eventType == MXEventTypeRoomCreate && roomState.hasRoomPredecessor)
if (event.eventType == MXEventTypeRoomCreate)
{
return [self roomCreatePredecessorAttributedStringFromRoomCreateContent:roomState.roomCreateContent];
MXRoomCreateContent *createContent = [MXRoomCreateContent modelFromJSON:event.content];
NSString *roomPredecessorId = createContent.roomPredecessorInfo.roomId;
if (roomPredecessorId)
{
return [self roomCreatePredecessorAttributedStringWithPredecessorRoomId:roomPredecessorId];
}
else
{
return nil;
}
}
NSAttributedString *attributedString = [super attributedStringFromEvent:event withRoomState:roomState error:error];
@ -559,14 +570,8 @@ NSString *const kEventFormatterOnReRequestKeysLinkActionSeparator = @"/";
#pragma mark - Room create predecessor
- (NSAttributedString*)roomCreatePredecessorAttributedStringFromRoomCreateContent:(MXRoomCreateContent*)roomCreateContent
- (NSAttributedString*)roomCreatePredecessorAttributedStringWithPredecessorRoomId:(NSString*)predecessorRoomId
{
if (!roomCreateContent)
{
return nil;
}
NSString *predecessorRoomId = roomCreateContent.roomPredecessorInfo.roomId;
NSString *predecessorRoomPermalink = [MXTools permalinkToRoom:predecessorRoomId];
NSDictionary *roomPredecessorReasonAttributes = @{