diff --git a/MatrixSDK/Data/MXRoom.m b/MatrixSDK/Data/MXRoom.m index 49c230b72a..7e59fcdae3 100644 --- a/MatrixSDK/Data/MXRoom.m +++ b/MatrixSDK/Data/MXRoom.m @@ -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) { diff --git a/MatrixSDK/MXSDKOptions.h b/MatrixSDK/MXSDKOptions.h index 780569b1f3..636941c9c0 100644 --- a/MatrixSDK/MXSDKOptions.h +++ b/MatrixSDK/MXSDKOptions.h @@ -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 diff --git a/MatrixSDK/MXSDKOptions.m b/MatrixSDK/MXSDKOptions.m index dd3385aa8a..3134cee842 100644 --- a/MatrixSDK/MXSDKOptions.m +++ b/MatrixSDK/MXSDKOptions.m @@ -52,7 +52,6 @@ - (instancetype)init self.roomListDataManagerClass = [MXCoreDataRoomListDataManager class]; _clientPermalinkBaseUrl = nil; _authEnableRefreshTokens = NO; - _enableThreads = NO; } return self; diff --git a/MatrixSDK/Threads/MXThreadingService.swift b/MatrixSDK/Threads/MXThreadingService.swift index 8458984c42..f9b7bba01b 100644 --- a/MatrixSDK/Threads/MXThreadingService.swift +++ b/MatrixSDK/Threads/MXThreadingService.swift @@ -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) diff --git a/MatrixSDKTests/MXThreadEventTimelineUnitTests.swift b/MatrixSDKTests/MXThreadEventTimelineUnitTests.swift index 396a031f31..85774bc776 100644 --- a/MatrixSDKTests/MXThreadEventTimelineUnitTests.swift +++ b/MatrixSDKTests/MXThreadEventTimelineUnitTests.swift @@ -30,7 +30,6 @@ class MXThreadEventTimelineUnitTests: XCTestCase { override class func setUp() { MXRealmCryptoStore.deleteAllStores() - MXSDKOptions.sharedInstance().enableThreads = true } func testLiveTimelineProperties() { diff --git a/MatrixSDKTests/MXThreadingServiceTests.swift b/MatrixSDKTests/MXThreadingServiceTests.swift index 9b306c630a..7e404318fb 100644 --- a/MatrixSDKTests/MXThreadingServiceTests.swift +++ b/MatrixSDKTests/MXThreadingServiceTests.swift @@ -22,7 +22,6 @@ class MXThreadingServiceTests: XCTestCase { override func setUp() { testData = MatrixSDKTestsData() - MXSDKOptions.sharedInstance().enableThreads = true } override func tearDown() { diff --git a/MatrixSDKTests/MXThreadingServiceUnitTests.swift b/MatrixSDKTests/MXThreadingServiceUnitTests.swift index 85688e3128..42aef463cf 100644 --- a/MatrixSDKTests/MXThreadingServiceUnitTests.swift +++ b/MatrixSDKTests/MXThreadingServiceUnitTests.swift @@ -32,7 +32,6 @@ class MXThreadingServiceUnitTests: XCTestCase { override class func setUp() { MXRealmCryptoStore.deleteAllStores() - MXSDKOptions.sharedInstance().enableThreads = true } func testInitialization() { diff --git a/changelog.d/5799.change b/changelog.d/5799.change new file mode 100644 index 0000000000..a12a640062 --- /dev/null +++ b/changelog.d/5799.change @@ -0,0 +1 @@ +MXSDKOptions: Remove `enableThreads` options, which is true by default now.