Use thread protocols where possible

This commit is contained in:
ismailgulek
2022-02-11 18:11:44 +03:00
parent e223bc6533
commit c740a8110e
8 changed files with 30 additions and 16 deletions
@@ -19,7 +19,7 @@
#import "MXKEventFormatter.h"
#import "MXKURLPreviewDataProtocol.h"
@class MXThread;
@protocol MXThreadProtocol;
/**
Flags to indicate if a fix is required at the display time.
@@ -108,7 +108,7 @@ typedef enum : NSUInteger {
/**
Thread for the bubble component. Should only exist for thread root events.
*/
@property (nonatomic, readonly) MXThread *thread;
@property (nonatomic, readonly) id<MXThreadProtocol> thread;
/**
Create a new `MXKRoomBubbleComponent` object based on a `MXEvent` instance.
@@ -22,7 +22,7 @@
@interface MXKRoomBubbleComponent ()
@property (nonatomic, readwrite) MXThread *thread;
@property (nonatomic, readwrite) id<MXThreadProtocol> thread;
@end
@@ -69,8 +69,17 @@
_showEncryptionBadge = [self shouldShowWarningBadgeForEvent:event roomState:(MXRoomState*)roomState session:session];
[self updateLinkWithRoomState:roomState];
self.thread = [session.threadingService threadWithId:event.eventId];
if (event.unsignedData.relations.thread)
{
self.thread = [[MXThreadModel alloc] initWithRootEvent:event
notificationCount:0
highlightCount:0];
}
else
{
self.thread = [session.threadingService threadWithId:event.eventId];
}
}
return self;
}