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

MXSDKOptions: Remove threads option #1413

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 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
67 changes: 32 additions & 35 deletions MatrixSDK/Data/MXRoom.m
Original file line number Diff line number Diff line change
Expand Up @@ -787,50 +787,47 @@ - (MXHTTPOperation*)_sendEventOfType:(MXEventTypeString)eventTypeString
BOOL startsThread = NO;
BOOL isReply = content[kMXEventRelationRelatesToKey][kMXEventContentRelatesToKeyInReplyTo][kMXEventContentRelatesToKeyEventId] != nil;
BOOL isEditing = [content[kMXEventRelationRelatesToKey][kMXEventContentRelatesToKeyRelationType] isEqualToString:MXEventRelationTypeReplace];
if (MXSDKOptions.sharedInstance.enableThreads)
if (threadId)
{
if (threadId)
inThread = YES;
NSMutableDictionary *mutableContent = [newContent mutableDeepCopy];
if (isReply)
{
inThread = YES;
NSMutableDictionary *mutableContent = [newContent mutableDeepCopy];
if (isReply)
// this will be a real in-thread reply
mutableContent[kMXEventRelationRelatesToKey][kMXEventContentRelatesToKeyIsReplyFallback] = @(NO);
}
else
{
// this will look like a reply, but only an in-thread event
NSString *lastEventId = [mxSession.threadingService threadWithId:threadId].lastMessage.eventId;
startsThread = lastEventId == nil;
NSString *replyToEventId = lastEventId ?: threadId;

if (mutableContent[kMXEventRelationRelatesToKey])
{
// this will be a real in-thread reply
mutableContent[kMXEventRelationRelatesToKey][kMXEventContentRelatesToKeyIsReplyFallback] = @(NO);
mutableContent[kMXEventRelationRelatesToKey][kMXEventContentRelatesToKeyInReplyTo] = @{
kMXEventContentRelatesToKeyEventId: replyToEventId
};
mutableContent[kMXEventRelationRelatesToKey][kMXEventContentRelatesToKeyIsReplyFallback] = @(YES);
}
else
{
// this will look like a reply, but only an in-thread event
NSString *lastEventId = [mxSession.threadingService threadWithId:threadId].lastMessage.eventId;
startsThread = lastEventId == nil;
NSString *replyToEventId = lastEventId ?: threadId;

if (mutableContent[kMXEventRelationRelatesToKey])
{
mutableContent[kMXEventRelationRelatesToKey][kMXEventContentRelatesToKeyInReplyTo] = @{
mutableContent[kMXEventRelationRelatesToKey] = @{
kMXEventContentRelatesToKeyIsReplyFallback: @(YES),
kMXEventContentRelatesToKeyInReplyTo: @{
kMXEventContentRelatesToKeyEventId: replyToEventId
};
mutableContent[kMXEventRelationRelatesToKey][kMXEventContentRelatesToKeyIsReplyFallback] = @(YES);
}
else
{
mutableContent[kMXEventRelationRelatesToKey] = @{
kMXEventContentRelatesToKeyIsReplyFallback: @(YES),
kMXEventContentRelatesToKeyInReplyTo: @{
kMXEventContentRelatesToKeyEventId: replyToEventId
}
};
}
}
};
}
newContent = mutableContent;
}
else if (isEditing)
{
// detect in-thread edits
NSString *editedEventId = content[kMXEventRelationRelatesToKey][kMXEventContentRelatesToKeyEventId];
MXEvent *editedEvent = [self.mxSession.store eventWithEventId:editedEventId inRoom:self.roomId];
inThread = editedEvent.isInThread;
}
newContent = mutableContent;
}
else if (isEditing)
{
// detect in-thread edits
NSString *editedEventId = content[kMXEventRelationRelatesToKey][kMXEventContentRelatesToKeyEventId];
MXEvent *editedEvent = [self.mxSession.store eventWithEventId:editedEventId inRoom:self.roomId];
inThread = editedEvent.isInThread;
}
return [mxSession.matrixRestClient sendEventToRoom:self.roomId threadId:threadId eventType:eventTypeString content:newContent txnId:txnId success:^(NSString *eventId) {

Expand Down
7 changes: 0 additions & 7 deletions MatrixSDK/MXSDKOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,6 @@ NS_ASSUME_NONNULL_BEGIN
*/
@property (nonatomic, assign) BOOL authEnableRefreshTokens;

/**
Enable threading module and thread-specific replies to events.

@remark NO by default.
*/
@property (nonatomic) BOOL enableThreads;

@end

NS_ASSUME_NONNULL_END
1 change: 0 additions & 1 deletion MatrixSDK/MXSDKOptions.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ - (instancetype)init
self.roomListDataManagerClass = [MXCoreDataRoomListDataManager class];
_clientPermalinkBaseUrl = nil;
_authEnableRefreshTokens = NO;
_enableThreads = NO;
}

return self;
Expand Down
5 changes: 0 additions & 5 deletions MatrixSDK/Threads/MXThreadingService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,6 @@ public class MXThreadingService: NSObject {
/// - direction: direction of the event
/// - completion: Completion block containing the flag indicating that the event is handled
public func handleEvent(_ event: MXEvent, direction: MXTimelineDirection, completion: ((Bool) -> Void)?) {
guard MXSDKOptions.sharedInstance().enableThreads else {
// threads disabled in the SDK
completion?(false)
return
}
guard let session = session else {
// session closed
completion?(false)
Expand Down
1 change: 0 additions & 1 deletion MatrixSDKTests/MXThreadEventTimelineUnitTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class MXThreadEventTimelineUnitTests: XCTestCase {

override class func setUp() {
MXRealmCryptoStore.deleteAllStores()
MXSDKOptions.sharedInstance().enableThreads = true
}

func testLiveTimelineProperties() {
Expand Down
1 change: 0 additions & 1 deletion MatrixSDKTests/MXThreadingServiceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class MXThreadingServiceTests: XCTestCase {

override func setUp() {
testData = MatrixSDKTestsData()
MXSDKOptions.sharedInstance().enableThreads = true
}

override func tearDown() {
Expand Down
1 change: 0 additions & 1 deletion MatrixSDKTests/MXThreadingServiceUnitTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class MXThreadingServiceUnitTests: XCTestCase {

override class func setUp() {
MXRealmCryptoStore.deleteAllStores()
MXSDKOptions.sharedInstance().enableThreads = true
}

func testInitialization() {
Expand Down
1 change: 1 addition & 0 deletions changelog.d/5799.change
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MXSDKOptions: Remove `enableThreads` options, which is true by default now.