Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search results bundled aggregations #5565

Merged
merged 5 commits into from
Feb 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ - (void)showRoomWithId:(NSString*)roomId
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];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ - (void)convertHomeserverResultsIntoCells:(MXSearchRoomEventResults *)roomEventR
{
continueBlock();
}
else if (result.result.unsignedData.relations.thread)
{
continueBlock();
}
else if (room)
{
[room liveTimeline:^(id<MXEventTimeline> liveTimeline) {
Expand Down Expand Up @@ -164,8 +168,9 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
{
if (cellData.hasThreadRoot)
{
MXThread *thread = cellData.bubbleComponents.firstObject.thread;
ThreadSummaryView *threadSummaryView = [[ThreadSummaryView alloc] initWithThread:thread];
id<MXThreadProtocol> thread = cellData.bubbleComponents.firstObject.thread;
ThreadSummaryView *threadSummaryView = [[ThreadSummaryView alloc] initWithThread:thread
session:self.mxSession];
[bubbleCell.tmpSubviews addObject:threadSummaryView];

threadSummaryView.translatesAutoresizingMaskIntoConstraints = NO;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ - (void)showRoomWithId:(NSString*)roomId
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];
Expand Down
4 changes: 2 additions & 2 deletions Riot/Modules/MatrixKit/Models/Room/MXKRoomBubbleComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
15 changes: 12 additions & 3 deletions Riot/Modules/MatrixKit/Models/Room/MXKRoomBubbleComponent.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

@interface MXKRoomBubbleComponent ()

@property (nonatomic, readwrite) MXThread *thread;
@property (nonatomic, readwrite) id<MXThreadProtocol> thread;

@end

Expand Down Expand Up @@ -69,8 +69,17 @@ - (instancetype)initWithEvent:(MXEvent*)event roomState:(MXRoomState*)roomState
_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;
}
Expand Down
2 changes: 1 addition & 1 deletion Riot/Modules/Room/DataSources/RoomDataSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,6 @@
@param roomDataSource room data source instance
*/
- (void)roomDataSource:(RoomDataSource * _Nonnull)roomDataSource
didTapThread:(MXThread * _Nonnull)thread;
didTapThread:(id<MXThreadProtocol> _Nonnull)thread;

@end
3 changes: 2 additions & 1 deletion Riot/Modules/Room/DataSources/RoomDataSource.m
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,8 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
// 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;

Expand Down
2 changes: 1 addition & 1 deletion Riot/Modules/Room/RoomViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -4283,7 +4283,7 @@ - (void)roomDataSourceDidUpdateEncryptionTrustLevel:(RoomDataSource *)roomDataSo
[self updateTitleViewEncryptionDecoration];
}

- (void)roomDataSource:(RoomDataSource *)roomDataSource didTapThread:(MXThread *)thread
- (void)roomDataSource:(RoomDataSource *)roomDataSource didTapThread:(id<MXThreadProtocol>)thread
{
[self openThreadWithId:thread.id];
}
Expand Down
9 changes: 7 additions & 2 deletions Riot/Modules/Room/Search/DataSources/RoomSearchDataSource.m
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ - (void)convertHomeserverResultsIntoCells:(MXSearchRoomEventResults *)roomEventR
{
continueBlock();
}
else if (result.result.unsignedData.relations.thread)
{
continueBlock();
}
else
{
[roomDataSource.room liveTimeline:^(id<MXEventTimeline> liveTimeline) {
Expand Down Expand Up @@ -143,8 +147,9 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
{
if (cellData.hasThreadRoot)
{
MXThread *thread = cellData.bubbleComponents.firstObject.thread;
ThreadSummaryView *threadSummaryView = [[ThreadSummaryView alloc] initWithThread:thread];
id<MXThreadProtocol> thread = cellData.bubbleComponents.firstObject.thread;
ThreadSummaryView *threadSummaryView = [[ThreadSummaryView alloc] initWithThread:thread
session:self.mxSession];
[bubbleCell.tmpSubviews addObject:threadSummaryView];

threadSummaryView.translatesAutoresizingMaskIntoConstraints = NO;
Expand Down
2 changes: 1 addition & 1 deletion Riot/Modules/Room/Search/RoomSearchViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ - (void)selectEvent:(MXEvent *)event
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];
Expand Down
10 changes: 6 additions & 4 deletions Riot/Modules/Room/Views/Threads/Summary/ThreadSummaryView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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(_:)))
Expand All @@ -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)))
Expand All @@ -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
}

Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions changelog.d/5562.change
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Search: Use bundled aggregations if provided.