mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:06:00 +00:00
@@ -2632,15 +2632,15 @@ class ClientProxyMock: ClientProxyProtocol {
|
||||
}
|
||||
//MARK: - roomPreviewForIdentifier
|
||||
|
||||
var roomPreviewForIdentifierUnderlyingCallsCount = 0
|
||||
var roomPreviewForIdentifierCallsCount: Int {
|
||||
var roomPreviewForIdentifierViaUnderlyingCallsCount = 0
|
||||
var roomPreviewForIdentifierViaCallsCount: Int {
|
||||
get {
|
||||
if Thread.isMainThread {
|
||||
return roomPreviewForIdentifierUnderlyingCallsCount
|
||||
return roomPreviewForIdentifierViaUnderlyingCallsCount
|
||||
} else {
|
||||
var returnValue: Int? = nil
|
||||
DispatchQueue.main.sync {
|
||||
returnValue = roomPreviewForIdentifierUnderlyingCallsCount
|
||||
returnValue = roomPreviewForIdentifierViaUnderlyingCallsCount
|
||||
}
|
||||
|
||||
return returnValue!
|
||||
@@ -2648,29 +2648,29 @@ class ClientProxyMock: ClientProxyProtocol {
|
||||
}
|
||||
set {
|
||||
if Thread.isMainThread {
|
||||
roomPreviewForIdentifierUnderlyingCallsCount = newValue
|
||||
roomPreviewForIdentifierViaUnderlyingCallsCount = newValue
|
||||
} else {
|
||||
DispatchQueue.main.sync {
|
||||
roomPreviewForIdentifierUnderlyingCallsCount = newValue
|
||||
roomPreviewForIdentifierViaUnderlyingCallsCount = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var roomPreviewForIdentifierCalled: Bool {
|
||||
return roomPreviewForIdentifierCallsCount > 0
|
||||
var roomPreviewForIdentifierViaCalled: Bool {
|
||||
return roomPreviewForIdentifierViaCallsCount > 0
|
||||
}
|
||||
var roomPreviewForIdentifierReceivedIdentifier: String?
|
||||
var roomPreviewForIdentifierReceivedInvocations: [String] = []
|
||||
var roomPreviewForIdentifierViaReceivedArguments: (identifier: String, via: [String])?
|
||||
var roomPreviewForIdentifierViaReceivedInvocations: [(identifier: String, via: [String])] = []
|
||||
|
||||
var roomPreviewForIdentifierUnderlyingReturnValue: Result<RoomPreviewDetails, ClientProxyError>!
|
||||
var roomPreviewForIdentifierReturnValue: Result<RoomPreviewDetails, ClientProxyError>! {
|
||||
var roomPreviewForIdentifierViaUnderlyingReturnValue: Result<RoomPreviewDetails, ClientProxyError>!
|
||||
var roomPreviewForIdentifierViaReturnValue: Result<RoomPreviewDetails, ClientProxyError>! {
|
||||
get {
|
||||
if Thread.isMainThread {
|
||||
return roomPreviewForIdentifierUnderlyingReturnValue
|
||||
return roomPreviewForIdentifierViaUnderlyingReturnValue
|
||||
} else {
|
||||
var returnValue: Result<RoomPreviewDetails, ClientProxyError>? = nil
|
||||
DispatchQueue.main.sync {
|
||||
returnValue = roomPreviewForIdentifierUnderlyingReturnValue
|
||||
returnValue = roomPreviewForIdentifierViaUnderlyingReturnValue
|
||||
}
|
||||
|
||||
return returnValue!
|
||||
@@ -2678,24 +2678,24 @@ class ClientProxyMock: ClientProxyProtocol {
|
||||
}
|
||||
set {
|
||||
if Thread.isMainThread {
|
||||
roomPreviewForIdentifierUnderlyingReturnValue = newValue
|
||||
roomPreviewForIdentifierViaUnderlyingReturnValue = newValue
|
||||
} else {
|
||||
DispatchQueue.main.sync {
|
||||
roomPreviewForIdentifierUnderlyingReturnValue = newValue
|
||||
roomPreviewForIdentifierViaUnderlyingReturnValue = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var roomPreviewForIdentifierClosure: ((String) async -> Result<RoomPreviewDetails, ClientProxyError>)?
|
||||
var roomPreviewForIdentifierViaClosure: ((String, [String]) async -> Result<RoomPreviewDetails, ClientProxyError>)?
|
||||
|
||||
func roomPreviewForIdentifier(_ identifier: String) async -> Result<RoomPreviewDetails, ClientProxyError> {
|
||||
roomPreviewForIdentifierCallsCount += 1
|
||||
roomPreviewForIdentifierReceivedIdentifier = identifier
|
||||
roomPreviewForIdentifierReceivedInvocations.append(identifier)
|
||||
if let roomPreviewForIdentifierClosure = roomPreviewForIdentifierClosure {
|
||||
return await roomPreviewForIdentifierClosure(identifier)
|
||||
func roomPreviewForIdentifier(_ identifier: String, via: [String]) async -> Result<RoomPreviewDetails, ClientProxyError> {
|
||||
roomPreviewForIdentifierViaCallsCount += 1
|
||||
roomPreviewForIdentifierViaReceivedArguments = (identifier: identifier, via: via)
|
||||
roomPreviewForIdentifierViaReceivedInvocations.append((identifier: identifier, via: via))
|
||||
if let roomPreviewForIdentifierViaClosure = roomPreviewForIdentifierViaClosure {
|
||||
return await roomPreviewForIdentifierViaClosure(identifier, via)
|
||||
} else {
|
||||
return roomPreviewForIdentifierReturnValue
|
||||
return roomPreviewForIdentifierViaReturnValue
|
||||
}
|
||||
}
|
||||
//MARK: - loadUserDisplayName
|
||||
|
||||
@@ -1093,18 +1093,18 @@ class SDKClientMock: SDKClientProtocol {
|
||||
return getRecentlyVisitedRoomsReturnValue
|
||||
}
|
||||
}
|
||||
//MARK: - getRoomPreview
|
||||
//MARK: - getRoomPreviewFromRoomAlias
|
||||
|
||||
public var getRoomPreviewRoomIdOrAliasThrowableError: Error?
|
||||
var getRoomPreviewRoomIdOrAliasUnderlyingCallsCount = 0
|
||||
public var getRoomPreviewRoomIdOrAliasCallsCount: Int {
|
||||
public var getRoomPreviewFromRoomAliasRoomAliasThrowableError: Error?
|
||||
var getRoomPreviewFromRoomAliasRoomAliasUnderlyingCallsCount = 0
|
||||
public var getRoomPreviewFromRoomAliasRoomAliasCallsCount: Int {
|
||||
get {
|
||||
if Thread.isMainThread {
|
||||
return getRoomPreviewRoomIdOrAliasUnderlyingCallsCount
|
||||
return getRoomPreviewFromRoomAliasRoomAliasUnderlyingCallsCount
|
||||
} else {
|
||||
var returnValue: Int? = nil
|
||||
DispatchQueue.main.sync {
|
||||
returnValue = getRoomPreviewRoomIdOrAliasUnderlyingCallsCount
|
||||
returnValue = getRoomPreviewFromRoomAliasRoomAliasUnderlyingCallsCount
|
||||
}
|
||||
|
||||
return returnValue!
|
||||
@@ -1112,29 +1112,29 @@ class SDKClientMock: SDKClientProtocol {
|
||||
}
|
||||
set {
|
||||
if Thread.isMainThread {
|
||||
getRoomPreviewRoomIdOrAliasUnderlyingCallsCount = newValue
|
||||
getRoomPreviewFromRoomAliasRoomAliasUnderlyingCallsCount = newValue
|
||||
} else {
|
||||
DispatchQueue.main.sync {
|
||||
getRoomPreviewRoomIdOrAliasUnderlyingCallsCount = newValue
|
||||
getRoomPreviewFromRoomAliasRoomAliasUnderlyingCallsCount = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public var getRoomPreviewRoomIdOrAliasCalled: Bool {
|
||||
return getRoomPreviewRoomIdOrAliasCallsCount > 0
|
||||
public var getRoomPreviewFromRoomAliasRoomAliasCalled: Bool {
|
||||
return getRoomPreviewFromRoomAliasRoomAliasCallsCount > 0
|
||||
}
|
||||
public var getRoomPreviewRoomIdOrAliasReceivedRoomIdOrAlias: String?
|
||||
public var getRoomPreviewRoomIdOrAliasReceivedInvocations: [String] = []
|
||||
public var getRoomPreviewFromRoomAliasRoomAliasReceivedRoomAlias: String?
|
||||
public var getRoomPreviewFromRoomAliasRoomAliasReceivedInvocations: [String] = []
|
||||
|
||||
var getRoomPreviewRoomIdOrAliasUnderlyingReturnValue: RoomPreview!
|
||||
public var getRoomPreviewRoomIdOrAliasReturnValue: RoomPreview! {
|
||||
var getRoomPreviewFromRoomAliasRoomAliasUnderlyingReturnValue: RoomPreview!
|
||||
public var getRoomPreviewFromRoomAliasRoomAliasReturnValue: RoomPreview! {
|
||||
get {
|
||||
if Thread.isMainThread {
|
||||
return getRoomPreviewRoomIdOrAliasUnderlyingReturnValue
|
||||
return getRoomPreviewFromRoomAliasRoomAliasUnderlyingReturnValue
|
||||
} else {
|
||||
var returnValue: RoomPreview? = nil
|
||||
DispatchQueue.main.sync {
|
||||
returnValue = getRoomPreviewRoomIdOrAliasUnderlyingReturnValue
|
||||
returnValue = getRoomPreviewFromRoomAliasRoomAliasUnderlyingReturnValue
|
||||
}
|
||||
|
||||
return returnValue!
|
||||
@@ -1142,27 +1142,99 @@ class SDKClientMock: SDKClientProtocol {
|
||||
}
|
||||
set {
|
||||
if Thread.isMainThread {
|
||||
getRoomPreviewRoomIdOrAliasUnderlyingReturnValue = newValue
|
||||
getRoomPreviewFromRoomAliasRoomAliasUnderlyingReturnValue = newValue
|
||||
} else {
|
||||
DispatchQueue.main.sync {
|
||||
getRoomPreviewRoomIdOrAliasUnderlyingReturnValue = newValue
|
||||
getRoomPreviewFromRoomAliasRoomAliasUnderlyingReturnValue = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public var getRoomPreviewRoomIdOrAliasClosure: ((String) async throws -> RoomPreview)?
|
||||
public var getRoomPreviewFromRoomAliasRoomAliasClosure: ((String) async throws -> RoomPreview)?
|
||||
|
||||
public func getRoomPreview(roomIdOrAlias: String) async throws -> RoomPreview {
|
||||
if let error = getRoomPreviewRoomIdOrAliasThrowableError {
|
||||
public func getRoomPreviewFromRoomAlias(roomAlias: String) async throws -> RoomPreview {
|
||||
if let error = getRoomPreviewFromRoomAliasRoomAliasThrowableError {
|
||||
throw error
|
||||
}
|
||||
getRoomPreviewRoomIdOrAliasCallsCount += 1
|
||||
getRoomPreviewRoomIdOrAliasReceivedRoomIdOrAlias = roomIdOrAlias
|
||||
getRoomPreviewRoomIdOrAliasReceivedInvocations.append(roomIdOrAlias)
|
||||
if let getRoomPreviewRoomIdOrAliasClosure = getRoomPreviewRoomIdOrAliasClosure {
|
||||
return try await getRoomPreviewRoomIdOrAliasClosure(roomIdOrAlias)
|
||||
getRoomPreviewFromRoomAliasRoomAliasCallsCount += 1
|
||||
getRoomPreviewFromRoomAliasRoomAliasReceivedRoomAlias = roomAlias
|
||||
getRoomPreviewFromRoomAliasRoomAliasReceivedInvocations.append(roomAlias)
|
||||
if let getRoomPreviewFromRoomAliasRoomAliasClosure = getRoomPreviewFromRoomAliasRoomAliasClosure {
|
||||
return try await getRoomPreviewFromRoomAliasRoomAliasClosure(roomAlias)
|
||||
} else {
|
||||
return getRoomPreviewRoomIdOrAliasReturnValue
|
||||
return getRoomPreviewFromRoomAliasRoomAliasReturnValue
|
||||
}
|
||||
}
|
||||
//MARK: - getRoomPreviewFromRoomId
|
||||
|
||||
public var getRoomPreviewFromRoomIdRoomIdViaServersThrowableError: Error?
|
||||
var getRoomPreviewFromRoomIdRoomIdViaServersUnderlyingCallsCount = 0
|
||||
public var getRoomPreviewFromRoomIdRoomIdViaServersCallsCount: Int {
|
||||
get {
|
||||
if Thread.isMainThread {
|
||||
return getRoomPreviewFromRoomIdRoomIdViaServersUnderlyingCallsCount
|
||||
} else {
|
||||
var returnValue: Int? = nil
|
||||
DispatchQueue.main.sync {
|
||||
returnValue = getRoomPreviewFromRoomIdRoomIdViaServersUnderlyingCallsCount
|
||||
}
|
||||
|
||||
return returnValue!
|
||||
}
|
||||
}
|
||||
set {
|
||||
if Thread.isMainThread {
|
||||
getRoomPreviewFromRoomIdRoomIdViaServersUnderlyingCallsCount = newValue
|
||||
} else {
|
||||
DispatchQueue.main.sync {
|
||||
getRoomPreviewFromRoomIdRoomIdViaServersUnderlyingCallsCount = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public var getRoomPreviewFromRoomIdRoomIdViaServersCalled: Bool {
|
||||
return getRoomPreviewFromRoomIdRoomIdViaServersCallsCount > 0
|
||||
}
|
||||
public var getRoomPreviewFromRoomIdRoomIdViaServersReceivedArguments: (roomId: String, viaServers: [String])?
|
||||
public var getRoomPreviewFromRoomIdRoomIdViaServersReceivedInvocations: [(roomId: String, viaServers: [String])] = []
|
||||
|
||||
var getRoomPreviewFromRoomIdRoomIdViaServersUnderlyingReturnValue: RoomPreview!
|
||||
public var getRoomPreviewFromRoomIdRoomIdViaServersReturnValue: RoomPreview! {
|
||||
get {
|
||||
if Thread.isMainThread {
|
||||
return getRoomPreviewFromRoomIdRoomIdViaServersUnderlyingReturnValue
|
||||
} else {
|
||||
var returnValue: RoomPreview? = nil
|
||||
DispatchQueue.main.sync {
|
||||
returnValue = getRoomPreviewFromRoomIdRoomIdViaServersUnderlyingReturnValue
|
||||
}
|
||||
|
||||
return returnValue!
|
||||
}
|
||||
}
|
||||
set {
|
||||
if Thread.isMainThread {
|
||||
getRoomPreviewFromRoomIdRoomIdViaServersUnderlyingReturnValue = newValue
|
||||
} else {
|
||||
DispatchQueue.main.sync {
|
||||
getRoomPreviewFromRoomIdRoomIdViaServersUnderlyingReturnValue = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public var getRoomPreviewFromRoomIdRoomIdViaServersClosure: ((String, [String]) async throws -> RoomPreview)?
|
||||
|
||||
public func getRoomPreviewFromRoomId(roomId: String, viaServers: [String]) async throws -> RoomPreview {
|
||||
if let error = getRoomPreviewFromRoomIdRoomIdViaServersThrowableError {
|
||||
throw error
|
||||
}
|
||||
getRoomPreviewFromRoomIdRoomIdViaServersCallsCount += 1
|
||||
getRoomPreviewFromRoomIdRoomIdViaServersReceivedArguments = (roomId: roomId, viaServers: viaServers)
|
||||
getRoomPreviewFromRoomIdRoomIdViaServersReceivedInvocations.append((roomId: roomId, viaServers: viaServers))
|
||||
if let getRoomPreviewFromRoomIdRoomIdViaServersClosure = getRoomPreviewFromRoomIdRoomIdViaServersClosure {
|
||||
return try await getRoomPreviewFromRoomIdRoomIdViaServersClosure(roomId, viaServers)
|
||||
} else {
|
||||
return getRoomPreviewFromRoomIdRoomIdViaServersReturnValue
|
||||
}
|
||||
}
|
||||
//MARK: - getSessionVerificationController
|
||||
|
||||
@@ -77,8 +77,7 @@ class JoinRoomScreenViewModel: JoinRoomScreenViewModelType, JoinRoomScreenViewMo
|
||||
hideLoadingIndicator()
|
||||
}
|
||||
|
||||
// We need an SDK update to pass the via into this preview.
|
||||
switch await clientProxy.roomPreviewForIdentifier(roomID) {
|
||||
switch await clientProxy.roomPreviewForIdentifier(roomID, via: via) {
|
||||
case .success(let roomDetails):
|
||||
state.roomDetails = roomDetails
|
||||
case .failure:
|
||||
|
||||
@@ -148,20 +148,20 @@ struct JoinRoomScreen_Previews: PreviewProvider, TestablePreview {
|
||||
}
|
||||
|
||||
if mode == .unknown {
|
||||
clientProxy.roomPreviewForIdentifierReturnValue = .failure(.sdkError(ClientProxyMockError.generic))
|
||||
clientProxy.roomPreviewForIdentifierViaReturnValue = .failure(.sdkError(ClientProxyMockError.generic))
|
||||
} else {
|
||||
clientProxy.roomPreviewForIdentifierReturnValue = .success(.init(roomID: "1",
|
||||
name: "The Three-Body Problem - 三体",
|
||||
canonicalAlias: "#3🌞problem:matrix.org",
|
||||
// swiftlint:disable:next line_length
|
||||
topic: "“Science and technology were the only keys to opening the door to the future, and people approached science with the faith and sincerity of elementary school students.”",
|
||||
avatarURL: URL.homeDirectory,
|
||||
memberCount: UInt(100),
|
||||
isHistoryWorldReadable: false,
|
||||
isJoined: membership.isJoined,
|
||||
isInvited: membership.isInvited,
|
||||
isPublic: membership.isPublic,
|
||||
canKnock: membership.canKnock))
|
||||
clientProxy.roomPreviewForIdentifierViaReturnValue = .success(.init(roomID: "1",
|
||||
name: "The Three-Body Problem - 三体",
|
||||
canonicalAlias: "#3🌞problem:matrix.org",
|
||||
// swiftlint:disable:next line_length
|
||||
topic: "“Science and technology were the only keys to opening the door to the future, and people approached science with the faith and sincerity of elementary school students.”",
|
||||
avatarURL: URL.homeDirectory,
|
||||
memberCount: UInt(100),
|
||||
isHistoryWorldReadable: false,
|
||||
isJoined: membership.isJoined,
|
||||
isInvited: membership.isInvited,
|
||||
isPublic: membership.isPublic,
|
||||
canKnock: membership.canKnock))
|
||||
}
|
||||
|
||||
return JoinRoomScreenViewModel(roomID: "1",
|
||||
|
||||
@@ -441,9 +441,9 @@ class ClientProxy: ClientProxyProtocol {
|
||||
room: room)
|
||||
}
|
||||
|
||||
func roomPreviewForIdentifier(_ identifier: String) async -> Result<RoomPreviewDetails, ClientProxyError> {
|
||||
func roomPreviewForIdentifier(_ identifier: String, via: [String]) async -> Result<RoomPreviewDetails, ClientProxyError> {
|
||||
do {
|
||||
let roomPreview = try await client.getRoomPreview(roomIdOrAlias: identifier)
|
||||
let roomPreview = try await client.getRoomPreviewFromRoomId(roomId: identifier, viaServers: via)
|
||||
return .success(.init(roomPreview))
|
||||
} catch {
|
||||
MXLog.error("Failed retrieving preview for room: \(identifier) with error: \(error)")
|
||||
|
||||
@@ -135,7 +135,7 @@ protocol ClientProxyProtocol: AnyObject, MediaLoaderProtocol {
|
||||
|
||||
func roomForIdentifier(_ identifier: String) async -> RoomProxyProtocol?
|
||||
|
||||
func roomPreviewForIdentifier(_ identifier: String) async -> Result<RoomPreviewDetails, ClientProxyError>
|
||||
func roomPreviewForIdentifier(_ identifier: String, via: [String]) async -> Result<RoomPreviewDetails, ClientProxyError>
|
||||
|
||||
@discardableResult func loadUserDisplayName() async -> Result<Void, ClientProxyError>
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ struct RoomEventStringBuilder {
|
||||
return stateEventStringBuilder
|
||||
.buildString(for: state, sender: sender, isOutgoing: isOutgoing)
|
||||
.map(AttributedString.init)
|
||||
case .roomMembership(let userID, let change):
|
||||
case .roomMembership(let userID, _, let change):
|
||||
return stateEventStringBuilder
|
||||
.buildString(for: change, member: userID, sender: sender, isOutgoing: isOutgoing)
|
||||
.map(AttributedString.init)
|
||||
|
||||
@@ -18,6 +18,12 @@ import Combine
|
||||
import Foundation
|
||||
import MatrixRustSDK
|
||||
|
||||
enum PaginationStatus {
|
||||
case idle
|
||||
case timelineEndReached
|
||||
case paginating
|
||||
}
|
||||
|
||||
struct PaginationState: Equatable {
|
||||
static var `default` = PaginationState(backward: .idle, forward: .timelineEndReached)
|
||||
let backward: PaginationStatus
|
||||
|
||||
@@ -59,7 +59,7 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol {
|
||||
return nil
|
||||
}
|
||||
return buildStateTimelineItem(for: eventItemProxy, state: content, isOutgoing: isOutgoing)
|
||||
case .roomMembership(userId: let userID, change: let change):
|
||||
case .roomMembership(userId: let userID, _, change: let change):
|
||||
if isDM, change == .joined, userID == self.userID {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -29,7 +29,8 @@ final class TimelineProxy: TimelineProxyProtocol {
|
||||
// periphery:ignore - retaining purpose
|
||||
private var timelineListener: RoomTimelineListener?
|
||||
|
||||
private let backPaginationStatusSubject = CurrentValueSubject<PaginationStatus, Never>(.idle)
|
||||
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>()
|
||||
|
||||
@@ -70,7 +71,15 @@ final class TimelineProxy: TimelineProxyProtocol {
|
||||
let result = await timeline.addListener(listener: timelineListener)
|
||||
roomTimelineObservationToken = result.itemsStream
|
||||
|
||||
let paginationStatePublisher = backPaginationStatusSubject
|
||||
// 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
|
||||
.combineLatest(forwardPaginationStatusSubject)
|
||||
.map { PaginationState(backward: $0.0, forward: $0.1) }
|
||||
.eraseToAnyPublisher()
|
||||
@@ -144,9 +153,11 @@ final class TimelineProxy: TimelineProxyProtocol {
|
||||
MXLog.info("Paginating backwards")
|
||||
|
||||
do {
|
||||
_ = try await timeline.paginateBackwards(numEvents: requestSize)
|
||||
let timelineEndReached = 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)")
|
||||
@@ -166,7 +177,7 @@ final class TimelineProxy: TimelineProxyProtocol {
|
||||
forwardPaginationStatusSubject.send(.paginating)
|
||||
|
||||
do {
|
||||
let timelineEndReached = try await timeline.focusedPaginateForwards(numEvents: 16)
|
||||
let timelineEndReached = try await timeline.focusedPaginateForwards(numEvents: requestSize)
|
||||
MXLog.info("Finished paginating forwards")
|
||||
|
||||
forwardPaginationStatusSubject.send(timelineEndReached ? .timelineEndReached : .idle)
|
||||
@@ -536,7 +547,16 @@ final class TimelineProxy: TimelineProxyProtocol {
|
||||
|
||||
private func subscribeToPagination() {
|
||||
let backPaginationListener = RoomPaginationStatusListener { [weak self] status in
|
||||
self?.backPaginationStatusSubject.send(status)
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
|
||||
switch status {
|
||||
case .initial, .idle:
|
||||
backPaginationSubscriptionSubject.send(.idle)
|
||||
case .fetchingTargetEvent, .paginating:
|
||||
backPaginationSubscriptionSubject.send(.paginating)
|
||||
}
|
||||
}
|
||||
do {
|
||||
backPaginationStatusObservationToken = try timeline.subscribeToBackPaginationStatus(listener: backPaginationListener)
|
||||
@@ -562,13 +582,13 @@ private final class RoomTimelineListener: TimelineListener {
|
||||
}
|
||||
|
||||
private final class RoomPaginationStatusListener: PaginationStatusListener {
|
||||
private let onUpdateClosure: (PaginationStatus) -> Void
|
||||
private let onUpdateClosure: (PaginatorState) -> Void
|
||||
|
||||
init(_ onUpdateClosure: @escaping (PaginationStatus) -> Void) {
|
||||
init(_ onUpdateClosure: @escaping (PaginatorState) -> Void) {
|
||||
self.onUpdateClosure = onUpdateClosure
|
||||
}
|
||||
|
||||
func onUpdate(status: PaginationStatus) {
|
||||
func onUpdate(status: PaginatorState) {
|
||||
onUpdateClosure(status)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user