mirror of
https://github.com/element-hq/element-x-ios.git
synced 2025-03-10 21:39:12 +00:00
Bump the RustSDK to v1.0.4, adopt new heroes and backpagination status APIs
This commit is contained in:
parent
e93e75778a
commit
ca16f63483
@ -7323,7 +7323,7 @@
|
||||
repositoryURL = "https://github.com/element-hq/matrix-rust-components-swift";
|
||||
requirement = {
|
||||
kind = exactVersion;
|
||||
version = 1.0.3;
|
||||
version = 1.0.4;
|
||||
};
|
||||
};
|
||||
701C7BEF8F70F7A83E852DCC /* XCRemoteSwiftPackageReference "GZIP" */ = {
|
||||
|
@ -139,8 +139,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/element-hq/matrix-rust-components-swift",
|
||||
"state" : {
|
||||
"revision" : "4e74b98191dbbc36025b23baa6cc272298e59de5",
|
||||
"version" : "1.0.3"
|
||||
"revision" : "100598671d3e6186f77e2f48630e9cbcb63fd86b",
|
||||
"version" : "1.0.4"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -138,7 +138,8 @@ class RoomProxy: RoomProxyProtocol {
|
||||
RequiredState(key: "m.room.avatar", value: ""),
|
||||
RequiredState(key: "m.room.canonical_alias", value: ""),
|
||||
RequiredState(key: "m.room.join_rules", value: "")],
|
||||
timelineLimit: UInt32(SlidingSyncConstants.defaultTimelineLimit))
|
||||
timelineLimit: UInt32(SlidingSyncConstants.defaultTimelineLimit),
|
||||
includeHeroes: false) // We don't need heroes here as they're already included in the `all_rooms` list
|
||||
roomListItem.subscribe(settings: settings)
|
||||
Self.subscriptionCountPerRoom[roomListItem.id()] = (Self.subscriptionCountPerRoom[roomListItem.id()] ?? 0) + 1
|
||||
|
||||
|
@ -30,7 +30,6 @@ final class TimelineProxy: TimelineProxyProtocol {
|
||||
private var timelineListener: RoomTimelineListener?
|
||||
|
||||
private let backPaginationSubscriptionSubject = CurrentValueSubject<PaginationStatus, Never>(.idle)
|
||||
private let backPaginationTimelineEndSubject = CurrentValueSubject<Bool, Never>(false)
|
||||
private let forwardPaginationStatusSubject = CurrentValueSubject<PaginationStatus, Never>(.timelineEndReached)
|
||||
private let timelineUpdatesSubject = PassthroughSubject<[TimelineDiff], Never>()
|
||||
|
||||
@ -71,20 +70,12 @@ final class TimelineProxy: TimelineProxyProtocol {
|
||||
let result = await timeline.addListener(listener: timelineListener)
|
||||
roomTimelineObservationToken = result.itemsStream
|
||||
|
||||
// Merge the subscription with the paginate method's return value.
|
||||
let backPaginationPublisher = backPaginationSubscriptionSubject
|
||||
.combineLatest(backPaginationTimelineEndSubject)
|
||||
.map { status, timelineEnd in
|
||||
timelineEnd ? .timelineEndReached : status
|
||||
}
|
||||
.eraseToAnyPublisher()
|
||||
|
||||
let paginationStatePublisher = backPaginationPublisher
|
||||
let paginationStatePublisher = backPaginationSubscriptionSubject
|
||||
.combineLatest(forwardPaginationStatusSubject)
|
||||
.map { PaginationState(backward: $0.0, forward: $0.1) }
|
||||
.eraseToAnyPublisher()
|
||||
|
||||
subscribeToPagination()
|
||||
await subscribeToPagination()
|
||||
|
||||
innerTimelineProvider = await RoomTimelineProvider(currentItems: result.items,
|
||||
isLive: isLive,
|
||||
@ -153,11 +144,9 @@ final class TimelineProxy: TimelineProxyProtocol {
|
||||
MXLog.info("Paginating backwards")
|
||||
|
||||
do {
|
||||
let timelineEndReached = try await timeline.paginateBackwards(numEvents: requestSize)
|
||||
let _ = try await timeline.paginateBackwards(numEvents: requestSize)
|
||||
MXLog.info("Finished paginating backwards")
|
||||
|
||||
backPaginationTimelineEndSubject.send(timelineEndReached)
|
||||
|
||||
return .success(())
|
||||
} catch {
|
||||
MXLog.error("Failed paginating backwards with error: \(error)")
|
||||
@ -545,21 +534,22 @@ final class TimelineProxy: TimelineProxyProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
private func subscribeToPagination() {
|
||||
private func subscribeToPagination() async {
|
||||
let backPaginationListener = RoomPaginationStatusListener { [weak self] status in
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
|
||||
switch status {
|
||||
case .initial, .idle:
|
||||
backPaginationSubscriptionSubject.send(.idle)
|
||||
case .fetchingTargetEvent, .paginating:
|
||||
case .idle(let hitStartOfTimeline):
|
||||
backPaginationSubscriptionSubject.send(hitStartOfTimeline ? .timelineEndReached : .idle)
|
||||
case .paginating:
|
||||
backPaginationSubscriptionSubject.send(.paginating)
|
||||
}
|
||||
}
|
||||
|
||||
do {
|
||||
backPaginationStatusObservationToken = try timeline.subscribeToBackPaginationStatus(listener: backPaginationListener)
|
||||
backPaginationStatusObservationToken = try await timeline.subscribeToBackPaginationStatus(listener: backPaginationListener)
|
||||
} catch {
|
||||
MXLog.error("Failed to subscribe to back pagination status with error: \(error)")
|
||||
}
|
||||
@ -582,13 +572,13 @@ private final class RoomTimelineListener: TimelineListener {
|
||||
}
|
||||
|
||||
private final class RoomPaginationStatusListener: PaginationStatusListener {
|
||||
private let onUpdateClosure: (PaginatorState) -> Void
|
||||
private let onUpdateClosure: (LiveBackPaginationStatus) -> Void
|
||||
|
||||
init(_ onUpdateClosure: @escaping (PaginatorState) -> Void) {
|
||||
init(_ onUpdateClosure: @escaping (LiveBackPaginationStatus) -> Void) {
|
||||
self.onUpdateClosure = onUpdateClosure
|
||||
}
|
||||
|
||||
func onUpdate(status: PaginatorState) {
|
||||
func onUpdate(status: LiveBackPaginationStatus) {
|
||||
onUpdateClosure(status)
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ packages:
|
||||
# Element/Matrix dependencies
|
||||
MatrixRustSDK:
|
||||
url: https://github.com/element-hq/matrix-rust-components-swift
|
||||
exactVersion: 1.0.3
|
||||
exactVersion: 1.0.4
|
||||
# path: ../matrix-rust-sdk
|
||||
Compound:
|
||||
url: https://github.com/element-hq/compound-ios
|
||||
|
Loading…
x
Reference in New Issue
Block a user