mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Enable the sliding sync timeline api. Start observing updates coming through the TimelineListener before addining a timeline listener on the Rust side
This commit is contained in:
committed by
Stefan Ceriu
parent
77d62b2c72
commit
cc51795bf0
@@ -36,11 +36,10 @@ class RoomProxy: RoomProxyProtocol {
|
|||||||
|
|
||||||
private var backPaginationOutcome: PaginationOutcome?
|
private var backPaginationOutcome: PaginationOutcome?
|
||||||
|
|
||||||
|
private var timelineObservationToken: StoppableSpawn?
|
||||||
|
|
||||||
deinit {
|
deinit {
|
||||||
room.removeTimeline()
|
timelineObservationToken?.cancel()
|
||||||
|
|
||||||
#warning("We **should** use the slidingSyncRoom but it's not working properly yet")
|
|
||||||
// slidingSyncRoom.removeTimeline()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
init(slidingSyncRoom: SlidingSyncRoomProtocol,
|
init(slidingSyncRoom: SlidingSyncRoomProtocol,
|
||||||
@@ -131,15 +130,12 @@ class RoomProxy: RoomProxyProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func addTimelineListener(listener: TimelineListener) -> Result<Void, RoomProxyError> {
|
func addTimelineListener(listener: TimelineListener) -> Result<Void, RoomProxyError> {
|
||||||
room.addTimelineListener(listener: listener)
|
if let token = slidingSyncRoom.addTimelineListener(listener: listener) {
|
||||||
return .success(())
|
timelineObservationToken = token
|
||||||
|
return .success(())
|
||||||
#warning("We **should** use the slidingSyncRoom but it's not working properly yet")
|
} else {
|
||||||
// if let result = slidingSyncRoom.addTimelineListener(listener: listener), result == true {
|
return .failure(.failedAddingTimelineListener)
|
||||||
// return .success(())
|
}
|
||||||
// } else {
|
|
||||||
// return .failure(.failedAddingTimelineListener)
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func paginateBackwards(count: UInt) async -> Result<UInt, RoomProxyError> {
|
func paginateBackwards(count: UInt) async -> Result<UInt, RoomProxyError> {
|
||||||
|
|||||||
@@ -51,18 +51,20 @@ class RoomTimelineProvider: RoomTimelineProviderProtocol {
|
|||||||
|
|
||||||
Task {
|
Task {
|
||||||
let roomTimelineListener = RoomTimelineListener()
|
let roomTimelineListener = RoomTimelineListener()
|
||||||
|
|
||||||
|
roomTimelineListener
|
||||||
|
.itemsUpdatePublisher
|
||||||
|
.receive(on: DispatchQueue.main)
|
||||||
|
// .collect(.byTime(serialDispatchQueue, 0.25))
|
||||||
|
.sink { [weak self] in self?.updateItemsWithDiffs([$0]) }
|
||||||
|
.store(in: &cancellables)
|
||||||
|
|
||||||
switch await roomProxy.addTimelineListener(listener: roomTimelineListener) {
|
switch await roomProxy.addTimelineListener(listener: roomTimelineListener) {
|
||||||
case .failure:
|
case .failure:
|
||||||
MXLog.error("Failed adding timeline listener on room with identifier: \(await roomProxy.id)")
|
MXLog.error("Failed adding timeline listener on room with identifier: \(await roomProxy.id)")
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
roomTimelineListener
|
|
||||||
.itemsUpdatePublisher
|
|
||||||
.collect(.byTime(serialDispatchQueue, 0.25))
|
|
||||||
.sink { [weak self] in self?.updateItemsWithDiffs($0) }
|
|
||||||
.store(in: &cancellables)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user