Skip to content

Commit

Permalink
Merge branch 'release/0.22.4/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
pixlwave committed Feb 25, 2022
2 parents a0c0b80 c31be6f commit 9f5477e
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 94 deletions.
7 changes: 7 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 1,10 @@
## Changes in 0.22.4 (2022-02-25)

🙌 Improvements

- MXThreadingService: Add thread creation delegate method. ([#5694](https://github.com/vector-im/element-ios/issues/5694))


## Changes in 0.22.3 (2022-02-24)

🐛 Bugfixes
Expand Down
2 changes: 1 addition & 1 deletion MatrixSDK.podspec
Original file line number Diff line number Diff line change
@@ -1,7 1,7 @@
Pod::Spec.new do |s|

s.name = "MatrixSDK"
s.version = "0.22.3"
s.version = "0.22.4"
s.summary = "The iOS SDK to build apps compatible with Matrix (https://www.matrix.org)"

s.description = <<-DESC
Expand Down
2 changes: 1 addition & 1 deletion MatrixSDK/Data/EventTimeline/Room/MXRoomEventTimeline.m
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 290,7 @@ - (MXHTTPOperation *)paginate:(NSUInteger)numItems direction:(MXTimelineDirectio
[self paginateFromStore:numItems direction:direction onComplete:^(NSArray<MXEvent *> *eventsFromStore) {
MXStrongifyAndReturnIfNil(self);

NSUInteger remainingNumItems = numItems;
NSInteger remainingNumItems = numItems;
NSUInteger eventsFromStoreCount = eventsFromStore.count;

if (direction == MXTimelineDirectionBackwards)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 216,8 @@ public class MXThreadEventTimeline: NSObject, MXEventTimeline {
paginateFromStore(numberOfItems: numItems, direction: direction) { [weak self] eventsFromStore in
guard let self = self else { return }

var remainingNumItems = numItems
let eventsFromStoreCount = UInt(eventsFromStore.count)
var remainingNumItems = Int(numItems)
let eventsFromStoreCount = eventsFromStore.count

if direction == .backwards {
// messagesFromStore are in chronological order
Expand All @@ -237,7 237,7 @@ public class MXThreadEventTimeline: NSObject, MXEventTimeline {
return
}

if remainingNumItems <= 0 && self.hasReachedHomeServerBackwardsPaginationEnd {
if remainingNumItems <= 0 || self.hasReachedHomeServerBackwardsPaginationEnd {
DispatchQueue.main.async {
// Nothing more to do
MXLog.debug("[MXThreadEventTimeline][\(self.timelineId)] paginate: is done from the store")
Expand Down Expand Up @@ -276,7 276,7 @@ public class MXThreadEventTimeline: NSObject, MXEventTimeline {
eventType: nil,
from: paginationToken,
direction: direction,
limit: remainingNumItems,
limit: UInt(remainingNumItems),
completion: { [weak self] response in
guard let self = self else { return }
switch response {
Expand Down
2 changes: 1 addition & 1 deletion MatrixSDK/MatrixSDKVersion.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 16,4 @@

#import <Foundation/Foundation.h>

NSString *const MatrixSDKVersion = @"0.22.3";
NSString *const MatrixSDKVersion = @"0.22.4";
23 changes: 14 additions & 9 deletions MatrixSDK/Threads/MXThreadingService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 37,13 @@ extension MXThreadingServiceError: CustomNSError {

@objc
public protocol MXThreadingServiceDelegate: AnyObject {
func threadingServiceDidUpdateThreads(_ service: MXThreadingService)
/// Delegate method to be called when thread are updated in any way.
@objc optional func threadingServiceDidUpdateThreads(_ service: MXThreadingService)

/// Delegate method to be called when a new local thread is created
@objc optional func threadingService(_ service: MXThreadingService,
didCreateNewThread thread: MXThread,
direction: MXTimelineDirection)
}

@objcMembers
Expand All @@ -49,10 55,7 @@ public class MXThreadingService: NSObject {
private let lockThreads = NSRecursiveLock()
private var threads: [String: MXThread] = [:]
private let multicastDelegate: MXMulticastDelegate<MXThreadingServiceDelegate> = MXMulticastDelegate()

/// Notification to be posted when a new thread is created.
public static let newThreadCreated = Notification.Name("MXThreadingService.newThreadCreated")


/// Initializer
/// - Parameter session: session instance
public init(withSession session: MXSession) {
Expand Down Expand Up @@ -244,9 247,7 @@ public class MXThreadingService: NSObject {
}
handled = thread.addEvent(event, direction: direction)
saveThread(thread)
DispatchQueue.main.async {
NotificationCenter.default.post(name: Self.newThreadCreated, object: thread, userInfo: nil)
}
notifyDidCreateThread(thread, direction: direction)
}
notifyDidUpdateThreads()
return handled
Expand Down Expand Up @@ -333,7 334,11 @@ public class MXThreadingService: NSObject {
}

private func notifyDidUpdateThreads() {
multicastDelegate.invoke({ $0.threadingServiceDidUpdateThreads(self) })
multicastDelegate.invoke({ $0.threadingServiceDidUpdateThreads?(self) })
}

private func notifyDidCreateThread(_ thread: MXThread, direction: MXTimelineDirection) {
multicastDelegate.invoke({ $0.threadingService?(self, didCreateNewThread: thread, direction: direction) })
}

}
Loading

0 comments on commit 9f5477e

Please sign in to comment.