diff --git a/Riot/Modules/GlobalSearch/Files/HomeFilesSearchViewController.m b/Riot/Modules/GlobalSearch/Files/HomeFilesSearchViewController.m index 5ec57f136..d51cfaa64 100644 --- a/Riot/Modules/GlobalSearch/Files/HomeFilesSearchViewController.m +++ b/Riot/Modules/GlobalSearch/Files/HomeFilesSearchViewController.m @@ -160,7 +160,7 @@ threadParameters = [[ThreadParameters alloc] initWithThreadId:event.threadId stackRoomScreen:NO]; } - else if ([self.mainSession.threadingService isEventThreadRoot:event]) + else if (event.unsignedData.relations.thread || [self.mainSession.threadingService isEventThreadRoot:event]) { threadParameters = [[ThreadParameters alloc] initWithThreadId:event.eventId stackRoomScreen:NO]; diff --git a/Riot/Modules/GlobalSearch/Messages/DataSources/HomeMessagesSearchDataSource.m b/Riot/Modules/GlobalSearch/Messages/DataSources/HomeMessagesSearchDataSource.m index 14a736b36..b136c9af4 100644 --- a/Riot/Modules/GlobalSearch/Messages/DataSources/HomeMessagesSearchDataSource.m +++ b/Riot/Modules/GlobalSearch/Messages/DataSources/HomeMessagesSearchDataSource.m @@ -89,6 +89,10 @@ { continueBlock(); } + else if (result.result.unsignedData.relations.thread) + { + continueBlock(); + } else if (room) { [room liveTimeline:^(id liveTimeline) { @@ -164,8 +168,9 @@ { if (cellData.hasThreadRoot) { - MXThread *thread = cellData.bubbleComponents.firstObject.thread; - ThreadSummaryView *threadSummaryView = [[ThreadSummaryView alloc] initWithThread:thread]; + id thread = cellData.bubbleComponents.firstObject.thread; + ThreadSummaryView *threadSummaryView = [[ThreadSummaryView alloc] initWithThread:thread + session:self.mxSession]; [bubbleCell.tmpSubviews addObject:threadSummaryView]; threadSummaryView.translatesAutoresizingMaskIntoConstraints = NO; diff --git a/Riot/Modules/GlobalSearch/Messages/HomeMessagesSearchViewController.m b/Riot/Modules/GlobalSearch/Messages/HomeMessagesSearchViewController.m index b8ba693be..8ba3d8241 100644 --- a/Riot/Modules/GlobalSearch/Messages/HomeMessagesSearchViewController.m +++ b/Riot/Modules/GlobalSearch/Messages/HomeMessagesSearchViewController.m @@ -167,7 +167,7 @@ threadParameters = [[ThreadParameters alloc] initWithThreadId:event.threadId stackRoomScreen:NO]; } - else if ([self.mainSession.threadingService isEventThreadRoot:event]) + else if (event.unsignedData.relations.thread || [self.mainSession.threadingService isEventThreadRoot:event]) { threadParameters = [[ThreadParameters alloc] initWithThreadId:event.eventId stackRoomScreen:NO]; diff --git a/Riot/Modules/MatrixKit/Models/Room/MXKRoomBubbleComponent.h b/Riot/Modules/MatrixKit/Models/Room/MXKRoomBubbleComponent.h index b778785e6..6ec53437e 100644 --- a/Riot/Modules/MatrixKit/Models/Room/MXKRoomBubbleComponent.h +++ b/Riot/Modules/MatrixKit/Models/Room/MXKRoomBubbleComponent.h @@ -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 thread; /** Create a new `MXKRoomBubbleComponent` object based on a `MXEvent` instance. diff --git a/Riot/Modules/MatrixKit/Models/Room/MXKRoomBubbleComponent.m b/Riot/Modules/MatrixKit/Models/Room/MXKRoomBubbleComponent.m index 9a244040e..25560044b 100644 --- a/Riot/Modules/MatrixKit/Models/Room/MXKRoomBubbleComponent.m +++ b/Riot/Modules/MatrixKit/Models/Room/MXKRoomBubbleComponent.m @@ -22,7 +22,7 @@ @interface MXKRoomBubbleComponent () -@property (nonatomic, readwrite) MXThread *thread; +@property (nonatomic, readwrite) id 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; } diff --git a/Riot/Modules/Room/DataSources/RoomDataSource.h b/Riot/Modules/Room/DataSources/RoomDataSource.h index 76d55375e..1ce04fc08 100644 --- a/Riot/Modules/Room/DataSources/RoomDataSource.h +++ b/Riot/Modules/Room/DataSources/RoomDataSource.h @@ -130,6 +130,6 @@ @param roomDataSource room data source instance */ - (void)roomDataSource:(RoomDataSource * _Nonnull)roomDataSource - didTapThread:(MXThread * _Nonnull)thread; + didTapThread:(id _Nonnull)thread; @end diff --git a/Riot/Modules/Room/DataSources/RoomDataSource.m b/Riot/Modules/Room/DataSources/RoomDataSource.m index f4561638f..82901062d 100644 --- a/Riot/Modules/Room/DataSources/RoomDataSource.m +++ b/Riot/Modules/Room/DataSources/RoomDataSource.m @@ -466,7 +466,8 @@ const CGFloat kTypingCellHeight = 24; // display thread summary view if the component has a thread in the room timeline if (RiotSettings.shared.enableThreads && component.thread && !self.threadId) { - threadSummaryView = [[ThreadSummaryView alloc] initWithThread:component.thread]; + threadSummaryView = [[ThreadSummaryView alloc] initWithThread:component.thread + session:self.mxSession]; threadSummaryView.delegate = self; threadSummaryView.tag = index; diff --git a/Riot/Modules/Room/RoomViewController.m b/Riot/Modules/Room/RoomViewController.m index 1c0e72410..e8ea422ed 100644 --- a/Riot/Modules/Room/RoomViewController.m +++ b/Riot/Modules/Room/RoomViewController.m @@ -4283,7 +4283,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; [self updateTitleViewEncryptionDecoration]; } -- (void)roomDataSource:(RoomDataSource *)roomDataSource didTapThread:(MXThread *)thread +- (void)roomDataSource:(RoomDataSource *)roomDataSource didTapThread:(id)thread { [self openThreadWithId:thread.id]; } diff --git a/Riot/Modules/Room/Search/DataSources/RoomSearchDataSource.m b/Riot/Modules/Room/Search/DataSources/RoomSearchDataSource.m index 5b99eea2d..dd33c86cb 100644 --- a/Riot/Modules/Room/Search/DataSources/RoomSearchDataSource.m +++ b/Riot/Modules/Room/Search/DataSources/RoomSearchDataSource.m @@ -96,6 +96,10 @@ { continueBlock(); } + else if (result.result.unsignedData.relations.thread) + { + continueBlock(); + } else { [roomDataSource.room liveTimeline:^(id liveTimeline) { @@ -143,8 +147,9 @@ { if (cellData.hasThreadRoot) { - MXThread *thread = cellData.bubbleComponents.firstObject.thread; - ThreadSummaryView *threadSummaryView = [[ThreadSummaryView alloc] initWithThread:thread]; + id thread = cellData.bubbleComponents.firstObject.thread; + ThreadSummaryView *threadSummaryView = [[ThreadSummaryView alloc] initWithThread:thread + session:self.mxSession]; [bubbleCell.tmpSubviews addObject:threadSummaryView]; threadSummaryView.translatesAutoresizingMaskIntoConstraints = NO; diff --git a/Riot/Modules/Room/Search/RoomSearchViewController.m b/Riot/Modules/Room/Search/RoomSearchViewController.m index 8097ca2b0..214f3f497 100644 --- a/Riot/Modules/Room/Search/RoomSearchViewController.m +++ b/Riot/Modules/Room/Search/RoomSearchViewController.m @@ -165,7 +165,7 @@ threadParameters = [[ThreadParameters alloc] initWithThreadId:event.threadId stackRoomScreen:NO]; } - else if ([self.mainSession.threadingService isEventThreadRoot:event]) + else if (event.unsignedData.relations.thread || [self.mainSession.threadingService isEventThreadRoot:event]) { threadParameters = [[ThreadParameters alloc] initWithThreadId:event.eventId stackRoomScreen:NO]; diff --git a/Riot/Modules/Room/Views/Threads/Summary/ThreadSummaryView.swift b/Riot/Modules/Room/Views/Threads/Summary/ThreadSummaryView.swift index c1da2d9dd..1a9799b27 100644 --- a/Riot/Modules/Room/Views/Threads/Summary/ThreadSummaryView.swift +++ b/Riot/Modules/Room/Views/Threads/Summary/ThreadSummaryView.swift @@ -38,7 +38,8 @@ class ThreadSummaryView: UIView { @IBOutlet private weak var lastMessageContentLabel: UILabel! private var theme: Theme = ThemeService.shared().theme - private(set) var thread: MXThread? + private(set) var thread: MXThreadProtocol? + private weak var session: MXSession? private lazy var tapGestureRecognizer: UITapGestureRecognizer = { return UITapGestureRecognizer(target: self, action: #selector(tapped(_:))) @@ -48,8 +49,9 @@ class ThreadSummaryView: UIView { // MARK: - Setup - init(withThread thread: MXThread) { + init(withThread thread: MXThreadProtocol, session: MXSession) { self.thread = thread + self.session = session super.init(frame: CGRect(origin: .zero, size: CGSize(width: Constants.viewDefaultWidth, height: RoomBubbleCellLayout.threadSummaryViewHeight))) @@ -59,7 +61,7 @@ class ThreadSummaryView: UIView { translatesAutoresizingMaskIntoConstraints = false } - static func contentViewHeight(forThread thread: MXThread?, fitting maxWidth: CGFloat) -> CGFloat { + static func contentViewHeight(forThread thread: MXThreadProtocol?, fitting maxWidth: CGFloat) -> CGFloat { return RoomBubbleCellLayout.threadSummaryViewHeight } @@ -93,7 +95,7 @@ class ThreadSummaryView: UIView { guard let thread = thread, let lastMessage = thread.lastMessage, - let session = thread.session, + let session = session, let eventFormatter = session.roomSummaryUpdateDelegate as? MXKEventFormatter, let room = session.room(withRoomId: lastMessage.roomId) else { lastMessageAvatarView.avatarImageView.image = nil diff --git a/changelog.d/5562.change b/changelog.d/5562.change new file mode 100644 index 000000000..729c93acc --- /dev/null +++ b/changelog.d/5562.change @@ -0,0 +1 @@ +Search: Use bundled aggregations if provided.