diff --git a/Config/CommonConfiguration.swift b/Config/CommonConfiguration.swift index 5802f8d778..0dc31f2fbe 100644 --- a/Config/CommonConfiguration.swift +++ b/Config/CommonConfiguration.swift @@ -72,9 +72,6 @@ class CommonConfiguration: NSObject, Configurable { // Disable key backup on common sdkOptions.enableKeyBackupWhenStartingMXCrypto = false - // Pass threading option to the SDK - sdkOptions.enableThreads = RiotSettings.shared.enableThreads - sdkOptions.clientPermalinkBaseUrl = BuildSettings.clientPermalinkBaseUrl sdkOptions.authEnableRefreshTokens = BuildSettings.authEnableRefreshTokens diff --git a/Riot/Assets/en.lproj/Vector.strings b/Riot/Assets/en.lproj/Vector.strings index ab8dfe66c1..d6f498cba3 100644 --- a/Riot/Assets/en.lproj/Vector.strings +++ b/Riot/Assets/en.lproj/Vector.strings @@ -637,7 +637,6 @@ Tap the + to start adding people."; "settings_labs_message_reaction" = "React to messages with emoji"; "settings_labs_enable_ringing_for_group_calls" = "Ring for group calls"; "settings_labs_enabled_polls" = "Polls"; -"settings_labs_enable_threads" = "Threaded messaging"; "settings_labs_enable_auto_report_decryption_errors" = "Auto Report Decryption Errors"; "settings_labs_use_only_latest_user_avatar_and_name" = "Show latest avatar and name for users in message history"; diff --git a/Riot/Generated/Strings.swift b/Riot/Generated/Strings.swift index d599c82969..182578b8af 100644 --- a/Riot/Generated/Strings.swift +++ b/Riot/Generated/Strings.swift @@ -6715,10 +6715,6 @@ public class VectorL10n: NSObject { public static var settingsLabsEnableRingingForGroupCalls: String { return VectorL10n.tr("Vector", "settings_labs_enable_ringing_for_group_calls") } - /// Threaded messaging - public static var settingsLabsEnableThreads: String { - return VectorL10n.tr("Vector", "settings_labs_enable_threads") - } /// Polls public static var settingsLabsEnabledPolls: String { return VectorL10n.tr("Vector", "settings_labs_enabled_polls") diff --git a/Riot/Managers/PushNotification/PushNotificationService.m b/Riot/Managers/PushNotification/PushNotificationService.m index 27b07292a1..a5800599a6 100644 --- a/Riot/Managers/PushNotification/PushNotificationService.m +++ b/Riot/Managers/PushNotification/PushNotificationService.m @@ -485,7 +485,7 @@ - (void)handleNotificationInlineReplyForRoomId:(NSString*)roomId // initialize data source for a thread or a room __block MXKRoomDataSource *dataSource; dispatch_group_t dispatchGroupDataSource = dispatch_group_create(); - if (RiotSettings.shared.enableThreads && threadId) + if (threadId) { dispatch_group_enter(dispatchGroupDataSource); [ThreadDataSource loadRoomDataSourceWithRoomId:roomId diff --git a/Riot/Managers/Settings/RiotSettings.swift b/Riot/Managers/Settings/RiotSettings.swift index 49516ddf9f..206c05564d 100644 --- a/Riot/Managers/Settings/RiotSettings.swift +++ b/Riot/Managers/Settings/RiotSettings.swift @@ -143,10 +143,6 @@ final class RiotSettings: NSObject { @UserDefault(key: "enableRingingForGroupCalls", defaultValue: false, storage: defaults) var enableRingingForGroupCalls - /// Indicates if threads enabled in the timeline. - @UserDefault(key: "enableThreads", defaultValue: false, storage: defaults) - var enableThreads - /// Indicates if auto reporting of decryption errors is enabled @UserDefault(key: UserDefaultsKeys.enableUISIAutoReporting, defaultValue: BuildSettings.cryptoUISIAutoReportingEnabled, storage: defaults) var enableUISIAutoReporting diff --git a/Riot/Modules/Application/LegacyAppDelegate.m b/Riot/Modules/Application/LegacyAppDelegate.m index aee43aaa30..9793665c03 100644 --- a/Riot/Modules/Application/LegacyAppDelegate.m +++ b/Riot/Modules/Application/LegacyAppDelegate.m @@ -1440,18 +1440,15 @@ - (BOOL)handleUniversalLinkWithParameters:(UniversalLinkParameters*)universalLin } ThreadParameters *threadParameters = nil; - if (RiotSettings.shared.enableThreads) + if (event.threadId) { - if (event.threadId) - { - threadParameters = [[ThreadParameters alloc] initWithThreadId:event.threadId - stackRoomScreen:NO]; - } - else if ([account.mxSession.threadingService threadWithId:eventId]) - { - threadParameters = [[ThreadParameters alloc] initWithThreadId:eventId - stackRoomScreen:NO]; - } + threadParameters = [[ThreadParameters alloc] initWithThreadId:event.threadId + stackRoomScreen:NO]; + } + else if ([account.mxSession.threadingService threadWithId:eventId]) + { + threadParameters = [[ThreadParameters alloc] initWithThreadId:eventId + stackRoomScreen:NO]; } RoomNavigationParameters *parameters = [[RoomNavigationParameters alloc] initWithRoomId:roomId @@ -3073,7 +3070,7 @@ - (void)showRoom:(NSString*)roomId threadId:(NSString*)threadId andEventId:(NSSt ScreenPresentationParameters *presentationParameters = [[ScreenPresentationParameters alloc] initWithRestoreInitialDisplay:YES]; ThreadParameters *threadParameters = nil; - if (RiotSettings.shared.enableThreads && threadId) + if (threadId) { threadParameters = [[ThreadParameters alloc] initWithThreadId:threadId stackRoomScreen:NO]; } diff --git a/Riot/Modules/GlobalSearch/Files/HomeFilesSearchViewController.m b/Riot/Modules/GlobalSearch/Files/HomeFilesSearchViewController.m index 04297d759d..95b50c9e70 100644 --- a/Riot/Modules/GlobalSearch/Files/HomeFilesSearchViewController.m +++ b/Riot/Modules/GlobalSearch/Files/HomeFilesSearchViewController.m @@ -143,18 +143,15 @@ - (void)showRoomWithId:(NSString*)roomId inMatrixSession:(MXSession*)session { ThreadParameters *threadParameters = nil; - if (RiotSettings.shared.enableThreads) + if (event.threadId) { - if (event.threadId) - { - threadParameters = [[ThreadParameters alloc] initWithThreadId:event.threadId - stackRoomScreen:NO]; - } - else if (event.unsignedData.relations.thread || [self.mainSession.threadingService isEventThreadRoot:event]) - { - threadParameters = [[ThreadParameters alloc] initWithThreadId:event.eventId - stackRoomScreen:NO]; - } + threadParameters = [[ThreadParameters alloc] initWithThreadId:event.threadId + stackRoomScreen:NO]; + } + else if (event.unsignedData.relations.thread || [self.mainSession.threadingService isEventThreadRoot:event]) + { + threadParameters = [[ThreadParameters alloc] initWithThreadId:event.eventId + stackRoomScreen:NO]; } ScreenPresentationParameters *presentationParameters = [[ScreenPresentationParameters alloc] initWithRestoreInitialDisplay:NO stackAboveVisibleViews:NO]; diff --git a/Riot/Modules/GlobalSearch/Messages/DataSources/HomeMessagesSearchDataSource.m b/Riot/Modules/GlobalSearch/Messages/DataSources/HomeMessagesSearchDataSource.m index f2f2cd4064..919cf122a0 100644 --- a/Riot/Modules/GlobalSearch/Messages/DataSources/HomeMessagesSearchDataSource.m +++ b/Riot/Modules/GlobalSearch/Messages/DataSources/HomeMessagesSearchDataSource.m @@ -83,34 +83,27 @@ - (void)convertHomeserverResultsIntoCells:(MXSearchRoomEventResults *)roomEventR dispatch_group_leave(group); }; - if (RiotSettings.shared.enableThreads) + if (result.result.isInThread) { - if (result.result.isInThread) - { - continueBlock(); - } - else if (result.result.unsignedData.relations.thread) - { - continueBlock(); - } - else if (room) - { - [room liveTimeline:^(id liveTimeline) { - [liveTimeline paginate:NSUIntegerMax - direction:MXTimelineDirectionBackwards - onlyFromStore:YES - complete:^{ - [liveTimeline resetPagination]; - continueBlock(); - } failure:^(NSError * _Nonnull error) { - continueBlock(); - }]; + continueBlock(); + } + else if (result.result.unsignedData.relations.thread) + { + continueBlock(); + } + else if (room) + { + [room liveTimeline:^(id liveTimeline) { + [liveTimeline paginate:NSUIntegerMax + direction:MXTimelineDirectionBackwards + onlyFromStore:YES + complete:^{ + [liveTimeline resetPagination]; + continueBlock(); + } failure:^(NSError * _Nonnull error) { + continueBlock(); }]; - } - else - { - continueBlock(); - } + }]; } else { @@ -159,63 +152,60 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N // Display date for each message [bubbleCell addDateLabel]; - if (RiotSettings.shared.enableThreads) - { - RoomBubbleCellData *cellData = (RoomBubbleCellData*)[self cellDataAtIndex:indexPath.row]; - MXEvent *event = cellData.events.firstObject; + RoomBubbleCellData *cellData = (RoomBubbleCellData*)[self cellDataAtIndex:indexPath.row]; + MXEvent *event = cellData.events.firstObject; - if (event) + if (event) + { + if (cellData.hasThreadRoot) { - if (cellData.hasThreadRoot) - { - id thread = cellData.bubbleComponents.firstObject.thread; - ThreadSummaryView *threadSummaryView = [[ThreadSummaryView alloc] initWithThread:thread - session:self.mxSession]; - [bubbleCell.tmpSubviews addObject:threadSummaryView]; - - threadSummaryView.translatesAutoresizingMaskIntoConstraints = NO; - [bubbleCell.contentView addSubview:threadSummaryView]; - - CGFloat leftMargin = PlainRoomCellLayoutConstants.reactionsViewLeftMargin; - CGFloat height = [ThreadSummaryView contentViewHeightForThread:thread fitting:cellData.maxTextViewWidth]; - - CGRect bubbleComponentFrame = [bubbleCell componentFrameInContentViewForIndex:0]; - CGFloat bottomPositionY = bubbleComponentFrame.origin.y + bubbleComponentFrame.size.height; - - // Set constraints for the summary view - [NSLayoutConstraint activateConstraints: @[ - [threadSummaryView.leadingAnchor constraintEqualToAnchor:threadSummaryView.superview.leadingAnchor - constant:leftMargin], - [threadSummaryView.topAnchor constraintEqualToAnchor:threadSummaryView.superview.topAnchor - constant:bottomPositionY + PlainRoomCellLayoutConstants.threadSummaryViewTopMargin], - [threadSummaryView.heightAnchor constraintEqualToConstant:height], - [threadSummaryView.trailingAnchor constraintLessThanOrEqualToAnchor:threadSummaryView.superview.trailingAnchor constant:-PlainRoomCellLayoutConstants.reactionsViewRightMargin] - ]]; - } - else if (event.isInThread) - { - FromAThreadView *fromAThreadView = [FromAThreadView instantiate]; - [bubbleCell.tmpSubviews addObject:fromAThreadView]; - - fromAThreadView.translatesAutoresizingMaskIntoConstraints = NO; - [bubbleCell.contentView addSubview:fromAThreadView]; - - CGFloat leftMargin = PlainRoomCellLayoutConstants.reactionsViewLeftMargin; - CGFloat height = [FromAThreadView contentViewHeightForEvent:event fitting:cellData.maxTextViewWidth]; - - CGRect bubbleComponentFrame = [bubbleCell componentFrameInContentViewForIndex:0]; - CGFloat bottomPositionY = bubbleComponentFrame.origin.y + bubbleComponentFrame.size.height; - - // Set constraints for the summary view - [NSLayoutConstraint activateConstraints: @[ - [fromAThreadView.leadingAnchor constraintEqualToAnchor:fromAThreadView.superview.leadingAnchor - constant:leftMargin], - [fromAThreadView.topAnchor constraintEqualToAnchor:fromAThreadView.superview.topAnchor - constant:bottomPositionY + PlainRoomCellLayoutConstants.fromAThreadViewTopMargin], - [fromAThreadView.heightAnchor constraintEqualToConstant:height], - [fromAThreadView.trailingAnchor constraintLessThanOrEqualToAnchor:fromAThreadView.superview.trailingAnchor constant:-PlainRoomCellLayoutConstants.reactionsViewRightMargin] - ]]; - } + id thread = cellData.bubbleComponents.firstObject.thread; + ThreadSummaryView *threadSummaryView = [[ThreadSummaryView alloc] initWithThread:thread + session:self.mxSession]; + [bubbleCell.tmpSubviews addObject:threadSummaryView]; + + threadSummaryView.translatesAutoresizingMaskIntoConstraints = NO; + [bubbleCell.contentView addSubview:threadSummaryView]; + + CGFloat leftMargin = PlainRoomCellLayoutConstants.reactionsViewLeftMargin; + CGFloat height = [ThreadSummaryView contentViewHeightForThread:thread fitting:cellData.maxTextViewWidth]; + + CGRect bubbleComponentFrame = [bubbleCell componentFrameInContentViewForIndex:0]; + CGFloat bottomPositionY = bubbleComponentFrame.origin.y + bubbleComponentFrame.size.height; + + // Set constraints for the summary view + [NSLayoutConstraint activateConstraints: @[ + [threadSummaryView.leadingAnchor constraintEqualToAnchor:threadSummaryView.superview.leadingAnchor + constant:leftMargin], + [threadSummaryView.topAnchor constraintEqualToAnchor:threadSummaryView.superview.topAnchor + constant:bottomPositionY + PlainRoomCellLayoutConstants.threadSummaryViewTopMargin], + [threadSummaryView.heightAnchor constraintEqualToConstant:height], + [threadSummaryView.trailingAnchor constraintLessThanOrEqualToAnchor:threadSummaryView.superview.trailingAnchor constant:-PlainRoomCellLayoutConstants.reactionsViewRightMargin] + ]]; + } + else if (event.isInThread) + { + FromAThreadView *fromAThreadView = [FromAThreadView instantiate]; + [bubbleCell.tmpSubviews addObject:fromAThreadView]; + + fromAThreadView.translatesAutoresizingMaskIntoConstraints = NO; + [bubbleCell.contentView addSubview:fromAThreadView]; + + CGFloat leftMargin = PlainRoomCellLayoutConstants.reactionsViewLeftMargin; + CGFloat height = [FromAThreadView contentViewHeightForEvent:event fitting:cellData.maxTextViewWidth]; + + CGRect bubbleComponentFrame = [bubbleCell componentFrameInContentViewForIndex:0]; + CGFloat bottomPositionY = bubbleComponentFrame.origin.y + bubbleComponentFrame.size.height; + + // Set constraints for the summary view + [NSLayoutConstraint activateConstraints: @[ + [fromAThreadView.leadingAnchor constraintEqualToAnchor:fromAThreadView.superview.leadingAnchor + constant:leftMargin], + [fromAThreadView.topAnchor constraintEqualToAnchor:fromAThreadView.superview.topAnchor + constant:bottomPositionY + PlainRoomCellLayoutConstants.fromAThreadViewTopMargin], + [fromAThreadView.heightAnchor constraintEqualToConstant:height], + [fromAThreadView.trailingAnchor constraintLessThanOrEqualToAnchor:fromAThreadView.superview.trailingAnchor constant:-PlainRoomCellLayoutConstants.reactionsViewRightMargin] + ]]; } } } diff --git a/Riot/Modules/GlobalSearch/Messages/HomeMessagesSearchViewController.m b/Riot/Modules/GlobalSearch/Messages/HomeMessagesSearchViewController.m index ea0c6a2f3b..26608cf9ab 100644 --- a/Riot/Modules/GlobalSearch/Messages/HomeMessagesSearchViewController.m +++ b/Riot/Modules/GlobalSearch/Messages/HomeMessagesSearchViewController.m @@ -150,18 +150,15 @@ - (void)showRoomWithId:(NSString*)roomId inMatrixSession:(MXSession*)session { ThreadParameters *threadParameters = nil; - if (RiotSettings.shared.enableThreads) + if (event.threadId) { - if (event.threadId) - { - threadParameters = [[ThreadParameters alloc] initWithThreadId:event.threadId - stackRoomScreen:NO]; - } - else if (event.unsignedData.relations.thread || [self.mainSession.threadingService isEventThreadRoot:event]) - { - threadParameters = [[ThreadParameters alloc] initWithThreadId:event.eventId - stackRoomScreen:NO]; - } + threadParameters = [[ThreadParameters alloc] initWithThreadId:event.threadId + stackRoomScreen:NO]; + } + else if (event.unsignedData.relations.thread || [self.mainSession.threadingService isEventThreadRoot:event]) + { + threadParameters = [[ThreadParameters alloc] initWithThreadId:event.eventId + stackRoomScreen:NO]; } ScreenPresentationParameters *screenParameters = [[ScreenPresentationParameters alloc] initWithRestoreInitialDisplay:NO stackAboveVisibleViews:NO]; diff --git a/Riot/Modules/MatrixKit/Utils/EventFormatter/MXKEventFormatter.m b/Riot/Modules/MatrixKit/Utils/EventFormatter/MXKEventFormatter.m index 2e196bc59e..1d3c26ba98 100644 --- a/Riot/Modules/MatrixKit/Utils/EventFormatter/MXKEventFormatter.m +++ b/Riot/Modules/MatrixKit/Utils/EventFormatter/MXKEventFormatter.m @@ -329,7 +329,7 @@ - (NSAttributedString *)attributedStringFromEvent:(MXEvent *)event withRoomState if (isRedacted) { // Check whether the event is a thread root or redacted information is required - if ((RiotSettings.shared.enableThreads && [mxSession.threadingService isEventThreadRoot:event]) + if (([mxSession.threadingService isEventThreadRoot:event]) || _settings.showRedactionsInRoomHistory) { MXLogDebug(@"[MXKEventFormatter] Redacted event %@ (%@)", event.description, event.redactedBecause); @@ -1266,31 +1266,12 @@ - (NSAttributedString *)attributedStringFromEvent:(MXEvent *)event withRoomState NSString *body; BOOL isHTML = NO; - NSString *eventThreadId = event.threadId; // Use the HTML formatted string if provided if ([contentToUse[@"format"] isEqualToString:kMXRoomMessageFormatHTML]) { - isHTML =YES; - MXJSONModelSetString(body, contentToUse[@"formatted_body"]); - } - else if (event.isReplyEvent || (eventThreadId && !RiotSettings.shared.enableThreads)) - { - NSString *repliedEventId = event.relatesTo.inReplyTo.eventId ?: eventThreadId; isHTML = YES; - MXJSONModelSetString(body, contentToUse[kMXMessageBodyKey]); - MXEvent *repliedEvent = [mxSession.store eventWithEventId:repliedEventId - inRoom:event.roomId]; - - NSString *repliedEventContent; - MXJSONModelSetString(repliedEventContent, repliedEvent.content[kMXMessageBodyKey]); - body = [NSString stringWithFormat:@"
In reply to %@
%@
%@", - [MXTools permalinkToEvent:repliedEventId inRoom:event.roomId], - [MXTools permalinkToUserWithUserId:repliedEvent.sender], - repliedEvent.sender, - repliedEventContent, - body]; - + MXJSONModelSetString(body, contentToUse[@"formatted_body"]); } else { @@ -1374,7 +1355,7 @@ - (NSAttributedString *)attributedStringFromEvent:(MXEvent *)event withRoomState // For replies, look for the end of the parent message // This helps us insert the emote prefix in the right place - if (event.relatesTo.inReplyTo || (!RiotSettings.shared.enableThreads && event.isInThread)) + if (event.relatesTo.inReplyTo) { [attributedDisplayText enumerateAttribute:kMXKToolsBlockquoteMarkAttribute inRange:NSMakeRange(0, attributedDisplayText.length) @@ -1754,7 +1735,7 @@ - (NSAttributedString*)renderHTMLString:(NSString*)htmlString forEvent:(MXEvent* NSString *html = htmlString; // Special treatment for "In reply to" message - if (event.isReplyEvent || (!RiotSettings.shared.enableThreads && event.isInThread)) + if (event.isReplyEvent) { html = [self renderReplyTo:html withRoomState:roomState]; } diff --git a/Riot/Modules/Room/CellData/RoomBubbleCellData.m b/Riot/Modules/Room/CellData/RoomBubbleCellData.m index 70ad44a482..dbb05d3312 100644 --- a/Riot/Modules/Room/CellData/RoomBubbleCellData.m +++ b/Riot/Modules/Room/CellData/RoomBubbleCellData.m @@ -284,12 +284,6 @@ - (BOOL)hasNoDisplay - (BOOL)hasThreadRoot { - if (!RiotSettings.shared.enableThreads) - { - // do not consider this cell data if threads not enabled in the timeline - return NO; - } - if (roomDataSource.threadId) { // do not consider this cell data if in a thread view @@ -680,11 +674,6 @@ - (void)setNeedsUpdateAdditionalContentHeight - (CGFloat)threadSummaryViewHeightForEventId:(NSString*)eventId { - if (!RiotSettings.shared.enableThreads) - { - // do not show thread summary view if threads not enabled in the timeline - return 0; - } if (roomDataSource.threadId) { // do not show thread summary view on threads @@ -707,11 +696,6 @@ - (CGFloat)threadSummaryViewHeightForEventId:(NSString*)eventId - (CGFloat)fromAThreadViewHeightForEventId:(NSString*)eventId { - if (!RiotSettings.shared.enableThreads) - { - // do not show from a thread view if threads not enabled - return 0; - } if (roomDataSource.threadId) { // do not show from a thread view on threads diff --git a/Riot/Modules/Room/DataSources/RoomDataSource.m b/Riot/Modules/Room/DataSources/RoomDataSource.m index 5e91b0d51a..9d7fe1004f 100644 --- a/Riot/Modules/Room/DataSources/RoomDataSource.m +++ b/Riot/Modules/Room/DataSources/RoomDataSource.m @@ -261,7 +261,7 @@ - (BOOL)shouldQueueEventForProcessing:(MXEvent *)event roomState:(MXRoomState *) } } } - else if (RiotSettings.shared.enableThreads) + else { // if not in a thread, ignore all threaded events if (event.isInThread) @@ -455,7 +455,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N ThreadSummaryView *threadSummaryView; // display thread summary view if the component has a thread in the room timeline - if (RiotSettings.shared.enableThreads && component.thread && !self.threadId) + if (component.thread && !self.threadId) { threadSummaryView = [[ThreadSummaryView alloc] initWithThread:component.thread session:self.mxSession]; diff --git a/Riot/Modules/Room/RoomViewController.m b/Riot/Modules/Room/RoomViewController.m index baf315b3ea..9f0e75c2de 100644 --- a/Riot/Modules/Room/RoomViewController.m +++ b/Riot/Modules/Room/RoomViewController.m @@ -660,7 +660,7 @@ - (void)viewDidAppear:(BOOL)animated self.showSettingsInitially = NO; - if (!RiotSettings.shared.threadsNoticeDisplayed && RiotSettings.shared.enableThreads) + if (!RiotSettings.shared.threadsNoticeDisplayed) { [self showThreadsNotice]; } @@ -1796,27 +1796,24 @@ - (void)refreshRoomTitle } [self refreshMissedDiscussionsCount:YES]; - - if (RiotSettings.shared.enableThreads) + + if (self.roomDataSource.threadId) { - if (self.roomDataSource.threadId) + // in a thread + if (rightBarButtonItems == nil) { - // in a thread - if (rightBarButtonItems == nil) - { - rightBarButtonItems = [NSMutableArray new]; - } - UIBarButtonItem *itemThreadMore = [self threadMoreBarButtonItem]; - [rightBarButtonItems insertObject:itemThreadMore atIndex:0]; - } - else - { - // in a regular timeline - UIBarButtonItem *itemThreadList = [self threadListBarButtonItem]; - [self updateThreadListBarButtonItem:itemThreadList - with:self.mainSession.threadingService]; - [rightBarButtonItems insertObject:itemThreadList atIndex:0]; + rightBarButtonItems = [NSMutableArray new]; } + UIBarButtonItem *itemThreadMore = [self threadMoreBarButtonItem]; + [rightBarButtonItems insertObject:itemThreadMore atIndex:0]; + } + else + { + // in a regular timeline + UIBarButtonItem *itemThreadList = [self threadListBarButtonItem]; + [self updateThreadListBarButtonItem:itemThreadList + with:self.mainSession.threadingService]; + [rightBarButtonItems insertObject:itemThreadList atIndex:0]; } } @@ -3482,9 +3479,7 @@ - (void)showAdditionalActionsMenuForEvent:(MXEvent*)selectedEvent inCell:(id *items = [NSMutableArray arrayWithCapacity:5]; diff --git a/Riot/Modules/Room/Search/DataSources/RoomSearchDataSource.m b/Riot/Modules/Room/Search/DataSources/RoomSearchDataSource.m index 9c0530a7ba..e4a6926912 100644 --- a/Riot/Modules/Room/Search/DataSources/RoomSearchDataSource.m +++ b/Riot/Modules/Room/Search/DataSources/RoomSearchDataSource.m @@ -90,35 +90,28 @@ - (void)convertHomeserverResultsIntoCells:(MXSearchRoomEventResults *)roomEventR dispatch_group_leave(group); }; - if (RiotSettings.shared.enableThreads) + if (result.result.isInThread) { - if (result.result.isInThread) - { - continueBlock(); - } - else if (result.result.unsignedData.relations.thread) - { - continueBlock(); - } - else - { - [roomDataSource.room liveTimeline:^(id liveTimeline) { - [liveTimeline paginate:NSUIntegerMax - direction:MXTimelineDirectionBackwards - onlyFromStore:YES - complete:^{ - [liveTimeline resetPagination]; - continueBlock(); - } failure:^(NSError * _Nonnull error) { - continueBlock(); - }]; - }]; - } + continueBlock(); } - else + else if (result.result.unsignedData.relations.thread) { continueBlock(); } + else + { + [roomDataSource.room liveTimeline:^(id liveTimeline) { + [liveTimeline paginate:NSUIntegerMax + direction:MXTimelineDirectionBackwards + onlyFromStore:YES + complete:^{ + [liveTimeline resetPagination]; + continueBlock(); + } failure:^(NSError * _Nonnull error) { + continueBlock(); + }]; + }]; + } } dispatch_group_notify(group, dispatch_get_main_queue(), ^{ @@ -138,63 +131,60 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N // Display date for each message [bubbleCell addDateLabel]; - if (RiotSettings.shared.enableThreads) + RoomBubbleCellData *cellData = (RoomBubbleCellData*)[self cellDataAtIndex:indexPath.row]; + MXEvent *event = cellData.events.firstObject; + + if (event) { - RoomBubbleCellData *cellData = (RoomBubbleCellData*)[self cellDataAtIndex:indexPath.row]; - MXEvent *event = cellData.events.firstObject; - - if (event) + if (cellData.hasThreadRoot) + { + id thread = cellData.bubbleComponents.firstObject.thread; + ThreadSummaryView *threadSummaryView = [[ThreadSummaryView alloc] initWithThread:thread + session:self.mxSession]; + [bubbleCell.tmpSubviews addObject:threadSummaryView]; + + threadSummaryView.translatesAutoresizingMaskIntoConstraints = NO; + [bubbleCell.contentView addSubview:threadSummaryView]; + + CGFloat leftMargin = PlainRoomCellLayoutConstants.reactionsViewLeftMargin; + CGFloat height = [ThreadSummaryView contentViewHeightForThread:thread fitting:cellData.maxTextViewWidth]; + + CGRect bubbleComponentFrame = [bubbleCell componentFrameInContentViewForIndex:0]; + CGFloat bottomPositionY = bubbleComponentFrame.origin.y + bubbleComponentFrame.size.height; + + // Set constraints for the summary view + [NSLayoutConstraint activateConstraints: @[ + [threadSummaryView.leadingAnchor constraintEqualToAnchor:threadSummaryView.superview.leadingAnchor + constant:leftMargin], + [threadSummaryView.topAnchor constraintEqualToAnchor:threadSummaryView.superview.topAnchor + constant:bottomPositionY + PlainRoomCellLayoutConstants.threadSummaryViewTopMargin], + [threadSummaryView.heightAnchor constraintEqualToConstant:height], + [threadSummaryView.trailingAnchor constraintLessThanOrEqualToAnchor:threadSummaryView.superview.trailingAnchor constant:-PlainRoomCellLayoutConstants.reactionsViewRightMargin] + ]]; + } + else if (event.isInThread) { - if (cellData.hasThreadRoot) - { - id thread = cellData.bubbleComponents.firstObject.thread; - ThreadSummaryView *threadSummaryView = [[ThreadSummaryView alloc] initWithThread:thread - session:self.mxSession]; - [bubbleCell.tmpSubviews addObject:threadSummaryView]; - - threadSummaryView.translatesAutoresizingMaskIntoConstraints = NO; - [bubbleCell.contentView addSubview:threadSummaryView]; - - CGFloat leftMargin = PlainRoomCellLayoutConstants.reactionsViewLeftMargin; - CGFloat height = [ThreadSummaryView contentViewHeightForThread:thread fitting:cellData.maxTextViewWidth]; - - CGRect bubbleComponentFrame = [bubbleCell componentFrameInContentViewForIndex:0]; - CGFloat bottomPositionY = bubbleComponentFrame.origin.y + bubbleComponentFrame.size.height; - - // Set constraints for the summary view - [NSLayoutConstraint activateConstraints: @[ - [threadSummaryView.leadingAnchor constraintEqualToAnchor:threadSummaryView.superview.leadingAnchor - constant:leftMargin], - [threadSummaryView.topAnchor constraintEqualToAnchor:threadSummaryView.superview.topAnchor - constant:bottomPositionY + PlainRoomCellLayoutConstants.threadSummaryViewTopMargin], - [threadSummaryView.heightAnchor constraintEqualToConstant:height], - [threadSummaryView.trailingAnchor constraintLessThanOrEqualToAnchor:threadSummaryView.superview.trailingAnchor constant:-PlainRoomCellLayoutConstants.reactionsViewRightMargin] - ]]; - } - else if (event.isInThread) - { - FromAThreadView *fromAThreadView = [FromAThreadView instantiate]; - [bubbleCell.tmpSubviews addObject:fromAThreadView]; - - fromAThreadView.translatesAutoresizingMaskIntoConstraints = NO; - [bubbleCell.contentView addSubview:fromAThreadView]; - - CGFloat leftMargin = PlainRoomCellLayoutConstants.reactionsViewLeftMargin; - CGFloat height = [FromAThreadView contentViewHeightForEvent:event fitting:cellData.maxTextViewWidth]; - - CGRect bubbleComponentFrame = [bubbleCell componentFrameInContentViewForIndex:0]; - CGFloat bottomPositionY = bubbleComponentFrame.origin.y + bubbleComponentFrame.size.height; - - // Set constraints for the summary view - [NSLayoutConstraint activateConstraints: @[ - [fromAThreadView.leadingAnchor constraintEqualToAnchor:fromAThreadView.superview.leadingAnchor - constant:leftMargin], - [fromAThreadView.topAnchor constraintEqualToAnchor:fromAThreadView.superview.topAnchor - constant:bottomPositionY + PlainRoomCellLayoutConstants.fromAThreadViewTopMargin], - [fromAThreadView.heightAnchor constraintEqualToConstant:height], - [fromAThreadView.trailingAnchor constraintLessThanOrEqualToAnchor:fromAThreadView.superview.trailingAnchor constant:-PlainRoomCellLayoutConstants.reactionsViewRightMargin] - ]]; - } + FromAThreadView *fromAThreadView = [FromAThreadView instantiate]; + [bubbleCell.tmpSubviews addObject:fromAThreadView]; + + fromAThreadView.translatesAutoresizingMaskIntoConstraints = NO; + [bubbleCell.contentView addSubview:fromAThreadView]; + + CGFloat leftMargin = PlainRoomCellLayoutConstants.reactionsViewLeftMargin; + CGFloat height = [FromAThreadView contentViewHeightForEvent:event fitting:cellData.maxTextViewWidth]; + + CGRect bubbleComponentFrame = [bubbleCell componentFrameInContentViewForIndex:0]; + CGFloat bottomPositionY = bubbleComponentFrame.origin.y + bubbleComponentFrame.size.height; + + // Set constraints for the summary view + [NSLayoutConstraint activateConstraints: @[ + [fromAThreadView.leadingAnchor constraintEqualToAnchor:fromAThreadView.superview.leadingAnchor + constant:leftMargin], + [fromAThreadView.topAnchor constraintEqualToAnchor:fromAThreadView.superview.topAnchor + constant:bottomPositionY + PlainRoomCellLayoutConstants.fromAThreadViewTopMargin], + [fromAThreadView.heightAnchor constraintEqualToConstant:height], + [fromAThreadView.trailingAnchor constraintLessThanOrEqualToAnchor:fromAThreadView.superview.trailingAnchor constant:-PlainRoomCellLayoutConstants.reactionsViewRightMargin] + ]]; } } } diff --git a/Riot/Modules/Room/Search/RoomSearchViewController.m b/Riot/Modules/Room/Search/RoomSearchViewController.m index 235d89798e..da4b3053c3 100644 --- a/Riot/Modules/Room/Search/RoomSearchViewController.m +++ b/Riot/Modules/Room/Search/RoomSearchViewController.m @@ -142,18 +142,15 @@ - (UIStatusBarStyle)preferredStatusBarStyle - (void)selectEvent:(MXEvent *)event { ThreadParameters *threadParameters = nil; - if (RiotSettings.shared.enableThreads) + if (event.threadId) { - if (event.threadId) - { - threadParameters = [[ThreadParameters alloc] initWithThreadId:event.threadId - stackRoomScreen:NO]; - } - else if (event.unsignedData.relations.thread || [self.mainSession.threadingService isEventThreadRoot:event]) - { - threadParameters = [[ThreadParameters alloc] initWithThreadId:event.eventId - stackRoomScreen:NO]; - } + threadParameters = [[ThreadParameters alloc] initWithThreadId:event.threadId + stackRoomScreen:NO]; + } + else if (event.unsignedData.relations.thread || [self.mainSession.threadingService isEventThreadRoot:event]) + { + threadParameters = [[ThreadParameters alloc] initWithThreadId:event.eventId + stackRoomScreen:NO]; } ScreenPresentationParameters *screenParameters = [[ScreenPresentationParameters alloc] initWithRestoreInitialDisplay:NO diff --git a/Riot/Modules/Settings/SettingsViewController.m b/Riot/Modules/Settings/SettingsViewController.m index 4cff1dac32..a777965fa9 100644 --- a/Riot/Modules/Settings/SettingsViewController.m +++ b/Riot/Modules/Settings/SettingsViewController.m @@ -158,7 +158,6 @@ typedef NS_ENUM(NSUInteger, ABOUT) typedef NS_ENUM(NSUInteger, LABS_ENABLE) { LABS_ENABLE_RINGING_FOR_GROUP_CALLS_INDEX = 0, - LABS_ENABLE_THREADS_INDEX, LABS_ENABLE_MESSAGE_BUBBLES_INDEX, LABS_ENABLE_AUTO_REPORT_DECRYPTION_ERRORS, LABS_USE_ONLY_LATEST_USER_AVATAR_AND_NAME_INDEX @@ -572,7 +571,6 @@ - (void)updateSections { Section *sectionLabs = [Section sectionWithTag:SECTION_TAG_LABS]; [sectionLabs addRowWithTag:LABS_ENABLE_RINGING_FOR_GROUP_CALLS_INDEX]; - [sectionLabs addRowWithTag:LABS_ENABLE_THREADS_INDEX]; [sectionLabs addRowWithTag:LABS_ENABLE_MESSAGE_BUBBLES_INDEX]; [sectionLabs addRowWithTag:LABS_ENABLE_AUTO_REPORT_DECRYPTION_ERRORS]; [sectionLabs addRowWithTag:LABS_USE_ONLY_LATEST_USER_AVATAR_AND_NAME_INDEX]; @@ -2459,18 +2457,6 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N cell = labelAndSwitchCell; } - else if (row == LABS_ENABLE_THREADS_INDEX) - { - MXKTableViewCellWithLabelAndSwitch *labelAndSwitchCell = [self getLabelAndSwitchCell:tableView forIndexPath:indexPath]; - - labelAndSwitchCell.mxkLabel.text = [VectorL10n settingsLabsEnableThreads]; - labelAndSwitchCell.mxkSwitch.on = RiotSettings.shared.enableThreads; - labelAndSwitchCell.mxkSwitch.onTintColor = ThemeService.shared.theme.tintColor; - - [labelAndSwitchCell.mxkSwitch addTarget:self action:@selector(toggleEnableThreads:) forControlEvents:UIControlEventTouchUpInside]; - - cell = labelAndSwitchCell; - } else if (row == LABS_ENABLE_MESSAGE_BUBBLES_INDEX) { cell = [self buildMessageBubblesCellForTableView:tableView atIndexPath:indexPath]; @@ -3218,14 +3204,6 @@ - (void)toggleEnableRingingForGroupCalls:(UISwitch *)sender RiotSettings.shared.enableRingingForGroupCalls = sender.isOn; } -- (void)toggleEnableThreads:(UISwitch *)sender -{ - RiotSettings.shared.enableThreads = sender.isOn; - MXSDKOptions.sharedInstance.enableThreads = sender.isOn; - [[MXKRoomDataSourceManager sharedManagerForMatrixSession:self.mainSession] reset]; - [[AppDelegate theDelegate] restoreEmptyDetailsViewController]; -} - - (void)togglePinRoomsWithMissedNotif:(UISwitch *)sender { RiotSettings.shared.pinRoomsWithMissedNotificationsOnHome = sender.isOn; diff --git a/Riot/Utils/EventFormatter.m b/Riot/Utils/EventFormatter.m index 64bd0f5d54..35b24b7cb9 100644 --- a/Riot/Utils/EventFormatter.m +++ b/Riot/Utils/EventFormatter.m @@ -103,7 +103,7 @@ - (NSAttributedString *)unsafeAttributedStringFromEvent:(MXEvent *)event withRoo if (event.isRedactedEvent) { // Check whether the event is a thread root or redacted information is required - if ((RiotSettings.shared.enableThreads && [mxSession.threadingService isEventThreadRoot:event]) + if ([mxSession.threadingService isEventThreadRoot:event] || self.settings.showRedactionsInRoomHistory) { UIFont *font = self.defaultTextFont; diff --git a/changelog.d/5799.change b/changelog.d/5799.change new file mode 100644 index 0000000000..71ad6f2b6a --- /dev/null +++ b/changelog.d/5799.change @@ -0,0 +1 @@ +Threads: Enable threads everywhere & remove labs setting.