mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
Bump the SDK and handle breaking changes on timeline diffing
- avoid race conditions between when a timeline listener starts publishing to the `updatePublisher` and when they are consumed (and in which order) - subscribe to the timeline directly in the TimelineProvider and correctly process updates serially - update the AutoUpdatingRoomTimelineProviderMock to use an SDK TimlineMock and listener to publish updates
This commit is contained in:
committed by
Stefan Ceriu
parent
b73e5e9e5d
commit
8b3141ffec
@@ -20,20 +20,25 @@ import MatrixRustSDK
|
||||
|
||||
@MainActor
|
||||
class AutoUpdatingRoomTimelineProviderMock: RoomTimelineProvider {
|
||||
private let innerUpdatePublisher: PassthroughSubject<[TimelineDiff], Never>
|
||||
static var timelineListener: TimelineListener?
|
||||
|
||||
private let innerPaginationStatePublisher: PassthroughSubject<PaginationState, Never>
|
||||
private let innerItems: [TimelineItemProxy] = []
|
||||
|
||||
init() {
|
||||
innerUpdatePublisher = .init()
|
||||
innerPaginationStatePublisher = .init()
|
||||
|
||||
super.init(currentItems: [],
|
||||
let timelineMock = TimelineSDKMock()
|
||||
|
||||
timelineMock.addListenerListenerClosure = { listener in
|
||||
Self.timelineListener = listener
|
||||
return TaskHandleSDKMock()
|
||||
}
|
||||
|
||||
super.init(timeline: timelineMock,
|
||||
isLive: true,
|
||||
updatePublisher: innerUpdatePublisher.eraseToAnyPublisher(),
|
||||
paginationStatePublisher: innerPaginationStatePublisher.eraseToAnyPublisher())
|
||||
|
||||
Task.detached { [weak self] in
|
||||
Task.detached {
|
||||
for _ in 0...100 {
|
||||
try? await Task.sleep(for: .seconds(1))
|
||||
|
||||
@@ -41,7 +46,7 @@ class AutoUpdatingRoomTimelineProviderMock: RoomTimelineProvider {
|
||||
diff.changeReturnValue = .append
|
||||
diff.appendReturnValue = [TimelineItemFixtures.messageTimelineItem]
|
||||
|
||||
self?.innerUpdatePublisher.send([diff])
|
||||
await Self.timelineListener?.onUpdate(diff: [diff])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user