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

Enable threads for all users #5868

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from
3 changes: 0 additions & 3 deletions Config/CommonConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion Riot/Assets/en.lproj/Vector.strings
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
4 changes: 0 additions & 4 deletions Riot/Generated/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion Riot/Managers/PushNotification/PushNotificationService.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions Riot/Managers/Settings/RiotSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 9 additions & 12 deletions Riot/Modules/Application/LegacyAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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];
}
Expand Down
19 changes: 8 additions & 11 deletions Riot/Modules/GlobalSearch/Files/HomeFilesSearchViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<MXEventTimeline> 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<MXEventTimeline> liveTimeline) {
[liveTimeline paginate:NSUIntegerMax
direction:MXTimelineDirectionBackwards
onlyFromStore:YES
complete:^{
[liveTimeline resetPagination];
continueBlock();
} failure:^(NSError * _Nonnull error) {
continueBlock();
}];
}
else
{
continueBlock();
}
}];
}
else
{
Expand Down Expand Up @@ -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<MXThreadProtocol> 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<MXThreadProtocol> 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]
]];
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
Loading