This commit is contained in:
ismailgulek
2021-02-03 14:01:29 +03:00
parent 7a231fead7
commit 0593e18d07
26 changed files with 983 additions and 29 deletions
+52 -19
View File
@@ -26,6 +26,7 @@
#import "DecryptionFailureTracker.h"
#import "EventFormatter+DTCoreTextFix.h"
#import <MatrixSDK/MatrixSDK.h>
#pragma mark - Constants definitions
@@ -168,30 +169,55 @@ static NSString *const kEventFormatterTimeFormat = @"HH:mm";
}
}
if (event.eventType == MXEventTypeRoomCreate)
switch (event.eventType)
{
MXRoomCreateContent *createContent = [MXRoomCreateContent modelFromJSON:event.content];
NSString *roomPredecessorId = createContent.roomPredecessorInfo.roomId;
if (roomPredecessorId)
case MXEventTypeRoomCreate:
{
return [self roomCreatePredecessorAttributedStringWithPredecessorRoomId:roomPredecessorId];
MXRoomCreateContent *createContent = [MXRoomCreateContent modelFromJSON:event.content];
NSString *roomPredecessorId = createContent.roomPredecessorInfo.roomId;
if (roomPredecessorId)
{
return [self roomCreatePredecessorAttributedStringWithPredecessorRoomId:roomPredecessorId];
}
else
{
NSAttributedString *string = [super attributedStringFromEvent:event withRoomState:roomState error:error];
NSMutableAttributedString *result = [[NSMutableAttributedString alloc] initWithString:@"· "];
[result appendAttributedString:string];
return result;
}
}
else
break;
case MXEventTypeCallCandidates:
case MXEventTypeCallAnswer:
case MXEventTypeCallSelectAnswer:
case MXEventTypeCallHangup:
case MXEventTypeCallNegotiate:
case MXEventTypeCallReplaces:
case MXEventTypeCallRejectReplacement:
// Do not show call events except invite and reject in timeline
return nil;
case MXEventTypeCallInvite:
{
NSAttributedString *string = [super attributedStringFromEvent:event withRoomState:roomState error:error];
NSMutableAttributedString *result = [[NSMutableAttributedString alloc] initWithString:@"· "];
[result appendAttributedString:string];
return result;
MXCallInviteEventContent *content = [MXCallInviteEventContent modelFromJSON:event.content];
MXCall *call = [mxSession.callManager callWithCallId:content.callId];
if (call && call.isIncoming && call.state == MXCallStateRinging)
{
// incoming call UI will be handled by CallKit (or incoming call screen if CallKit disabled)
// do not show a bubble for this case
return nil;
}
}
}
// Make event types MXEventTypeKeyVerificationCancel and MXEventTypeKeyVerificationDone visible in timeline.
// TODO: Find another way to keep them visible and avoid instantiate empty NSMutableAttributedString.
if (event.eventType == MXEventTypeKeyVerificationCancel || event.eventType == MXEventTypeKeyVerificationDone)
{
return [NSMutableAttributedString new];
break;
case MXEventTypeKeyVerificationCancel:
case MXEventTypeKeyVerificationDone:
// Make event types MXEventTypeKeyVerificationCancel and MXEventTypeKeyVerificationDone visible in timeline.
// TODO: Find another way to keep them visible and avoid instantiate empty NSMutableAttributedString.
return [NSMutableAttributedString new];
default:
break;
}
NSAttributedString *attributedString = [super attributedStringFromEvent:event withRoomState:roomState error:error];
@@ -265,6 +291,8 @@ static NSString *const kEventFormatterTimeFormat = @"HH:mm";
{
MXEvent *roomCreateEvent = [events filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"type == %@", kMXEventTypeStringRoomCreate]].firstObject;
MXEvent *callInviteEvent = [events filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"type == %@", kMXEventTypeStringCallInvite]].firstObject;
if (roomCreateEvent)
{
MXKEventFormatterError tmpError;
@@ -287,6 +315,11 @@ static NSString *const kEventFormatterTimeFormat = @"HH:mm";
[result appendAttributedString:linkMore];
return result;
}
else if (callInviteEvent)
{
// return a non-nil value
return [NSMutableAttributedString new];
}
else if (events[0].eventType == MXEventTypeRoomMember)
{
// This is a series for cells tagged with RoomBubbleCellDataTagMembership