diff --git a/ElementX.xcodeproj/project.pbxproj b/ElementX.xcodeproj/project.pbxproj index c1e2b448f..7ed79f0ee 100644 --- a/ElementX.xcodeproj/project.pbxproj +++ b/ElementX.xcodeproj/project.pbxproj @@ -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" */ = { diff --git a/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 5f1a69743..518b568fb 100644 --- a/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -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" } }, { diff --git a/ElementX/Sources/Services/Room/RoomProxy.swift b/ElementX/Sources/Services/Room/RoomProxy.swift index c7bc59fdd..38807cd8c 100644 --- a/ElementX/Sources/Services/Room/RoomProxy.swift +++ b/ElementX/Sources/Services/Room/RoomProxy.swift @@ -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 diff --git a/ElementX/Sources/Services/Timeline/TimelineProxy.swift b/ElementX/Sources/Services/Timeline/TimelineProxy.swift index 78eeab688..c8231eea7 100644 --- a/ElementX/Sources/Services/Timeline/TimelineProxy.swift +++ b/ElementX/Sources/Services/Timeline/TimelineProxy.swift @@ -30,7 +30,6 @@ final class TimelineProxy: TimelineProxyProtocol { private var timelineListener: RoomTimelineListener? private let backPaginationSubscriptionSubject = CurrentValueSubject(.idle) - private let backPaginationTimelineEndSubject = CurrentValueSubject(false) private let forwardPaginationStatusSubject = CurrentValueSubject(.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) } } diff --git a/project.yml b/project.yml index e8f6eeb11..62414cbff 100644 --- a/project.yml +++ b/project.yml @@ -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