mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
@@ -7308,7 +7308,7 @@
|
|||||||
repositoryURL = "https://github.com/element-hq/matrix-rust-components-swift";
|
repositoryURL = "https://github.com/element-hq/matrix-rust-components-swift";
|
||||||
requirement = {
|
requirement = {
|
||||||
kind = exactVersion;
|
kind = exactVersion;
|
||||||
version = 1.0.0;
|
version = 1.0.1;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
701C7BEF8F70F7A83E852DCC /* XCRemoteSwiftPackageReference "GZIP" */ = {
|
701C7BEF8F70F7A83E852DCC /* XCRemoteSwiftPackageReference "GZIP" */ = {
|
||||||
|
|||||||
@@ -139,8 +139,8 @@
|
|||||||
"kind" : "remoteSourceControl",
|
"kind" : "remoteSourceControl",
|
||||||
"location" : "https://github.com/element-hq/matrix-rust-components-swift",
|
"location" : "https://github.com/element-hq/matrix-rust-components-swift",
|
||||||
"state" : {
|
"state" : {
|
||||||
"revision" : "7437bbf102fb5dafb4e61aad6b9aa43dc34db0cc",
|
"revision" : "dfd7a1e7ad140e3c3e186301a20a53a6628f1bb8",
|
||||||
"version" : "1.0.0"
|
"version" : "1.0.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2632,15 +2632,15 @@ class ClientProxyMock: ClientProxyProtocol {
|
|||||||
}
|
}
|
||||||
//MARK: - roomPreviewForIdentifier
|
//MARK: - roomPreviewForIdentifier
|
||||||
|
|
||||||
var roomPreviewForIdentifierUnderlyingCallsCount = 0
|
var roomPreviewForIdentifierViaUnderlyingCallsCount = 0
|
||||||
var roomPreviewForIdentifierCallsCount: Int {
|
var roomPreviewForIdentifierViaCallsCount: Int {
|
||||||
get {
|
get {
|
||||||
if Thread.isMainThread {
|
if Thread.isMainThread {
|
||||||
return roomPreviewForIdentifierUnderlyingCallsCount
|
return roomPreviewForIdentifierViaUnderlyingCallsCount
|
||||||
} else {
|
} else {
|
||||||
var returnValue: Int? = nil
|
var returnValue: Int? = nil
|
||||||
DispatchQueue.main.sync {
|
DispatchQueue.main.sync {
|
||||||
returnValue = roomPreviewForIdentifierUnderlyingCallsCount
|
returnValue = roomPreviewForIdentifierViaUnderlyingCallsCount
|
||||||
}
|
}
|
||||||
|
|
||||||
return returnValue!
|
return returnValue!
|
||||||
@@ -2648,29 +2648,29 @@ class ClientProxyMock: ClientProxyProtocol {
|
|||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
if Thread.isMainThread {
|
if Thread.isMainThread {
|
||||||
roomPreviewForIdentifierUnderlyingCallsCount = newValue
|
roomPreviewForIdentifierViaUnderlyingCallsCount = newValue
|
||||||
} else {
|
} else {
|
||||||
DispatchQueue.main.sync {
|
DispatchQueue.main.sync {
|
||||||
roomPreviewForIdentifierUnderlyingCallsCount = newValue
|
roomPreviewForIdentifierViaUnderlyingCallsCount = newValue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var roomPreviewForIdentifierCalled: Bool {
|
var roomPreviewForIdentifierViaCalled: Bool {
|
||||||
return roomPreviewForIdentifierCallsCount > 0
|
return roomPreviewForIdentifierViaCallsCount > 0
|
||||||
}
|
}
|
||||||
var roomPreviewForIdentifierReceivedIdentifier: String?
|
var roomPreviewForIdentifierViaReceivedArguments: (identifier: String, via: [String])?
|
||||||
var roomPreviewForIdentifierReceivedInvocations: [String] = []
|
var roomPreviewForIdentifierViaReceivedInvocations: [(identifier: String, via: [String])] = []
|
||||||
|
|
||||||
var roomPreviewForIdentifierUnderlyingReturnValue: Result<RoomPreviewDetails, ClientProxyError>!
|
var roomPreviewForIdentifierViaUnderlyingReturnValue: Result<RoomPreviewDetails, ClientProxyError>!
|
||||||
var roomPreviewForIdentifierReturnValue: Result<RoomPreviewDetails, ClientProxyError>! {
|
var roomPreviewForIdentifierViaReturnValue: Result<RoomPreviewDetails, ClientProxyError>! {
|
||||||
get {
|
get {
|
||||||
if Thread.isMainThread {
|
if Thread.isMainThread {
|
||||||
return roomPreviewForIdentifierUnderlyingReturnValue
|
return roomPreviewForIdentifierViaUnderlyingReturnValue
|
||||||
} else {
|
} else {
|
||||||
var returnValue: Result<RoomPreviewDetails, ClientProxyError>? = nil
|
var returnValue: Result<RoomPreviewDetails, ClientProxyError>? = nil
|
||||||
DispatchQueue.main.sync {
|
DispatchQueue.main.sync {
|
||||||
returnValue = roomPreviewForIdentifierUnderlyingReturnValue
|
returnValue = roomPreviewForIdentifierViaUnderlyingReturnValue
|
||||||
}
|
}
|
||||||
|
|
||||||
return returnValue!
|
return returnValue!
|
||||||
@@ -2678,24 +2678,24 @@ class ClientProxyMock: ClientProxyProtocol {
|
|||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
if Thread.isMainThread {
|
if Thread.isMainThread {
|
||||||
roomPreviewForIdentifierUnderlyingReturnValue = newValue
|
roomPreviewForIdentifierViaUnderlyingReturnValue = newValue
|
||||||
} else {
|
} else {
|
||||||
DispatchQueue.main.sync {
|
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> {
|
func roomPreviewForIdentifier(_ identifier: String, via: [String]) async -> Result<RoomPreviewDetails, ClientProxyError> {
|
||||||
roomPreviewForIdentifierCallsCount += 1
|
roomPreviewForIdentifierViaCallsCount += 1
|
||||||
roomPreviewForIdentifierReceivedIdentifier = identifier
|
roomPreviewForIdentifierViaReceivedArguments = (identifier: identifier, via: via)
|
||||||
roomPreviewForIdentifierReceivedInvocations.append(identifier)
|
roomPreviewForIdentifierViaReceivedInvocations.append((identifier: identifier, via: via))
|
||||||
if let roomPreviewForIdentifierClosure = roomPreviewForIdentifierClosure {
|
if let roomPreviewForIdentifierViaClosure = roomPreviewForIdentifierViaClosure {
|
||||||
return await roomPreviewForIdentifierClosure(identifier)
|
return await roomPreviewForIdentifierViaClosure(identifier, via)
|
||||||
} else {
|
} else {
|
||||||
return roomPreviewForIdentifierReturnValue
|
return roomPreviewForIdentifierViaReturnValue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//MARK: - loadUserDisplayName
|
//MARK: - loadUserDisplayName
|
||||||
|
|||||||
@@ -1093,18 +1093,18 @@ class SDKClientMock: SDKClientProtocol {
|
|||||||
return getRecentlyVisitedRoomsReturnValue
|
return getRecentlyVisitedRoomsReturnValue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//MARK: - getRoomPreview
|
//MARK: - getRoomPreviewFromRoomAlias
|
||||||
|
|
||||||
public var getRoomPreviewRoomIdOrAliasThrowableError: Error?
|
public var getRoomPreviewFromRoomAliasRoomAliasThrowableError: Error?
|
||||||
var getRoomPreviewRoomIdOrAliasUnderlyingCallsCount = 0
|
var getRoomPreviewFromRoomAliasRoomAliasUnderlyingCallsCount = 0
|
||||||
public var getRoomPreviewRoomIdOrAliasCallsCount: Int {
|
public var getRoomPreviewFromRoomAliasRoomAliasCallsCount: Int {
|
||||||
get {
|
get {
|
||||||
if Thread.isMainThread {
|
if Thread.isMainThread {
|
||||||
return getRoomPreviewRoomIdOrAliasUnderlyingCallsCount
|
return getRoomPreviewFromRoomAliasRoomAliasUnderlyingCallsCount
|
||||||
} else {
|
} else {
|
||||||
var returnValue: Int? = nil
|
var returnValue: Int? = nil
|
||||||
DispatchQueue.main.sync {
|
DispatchQueue.main.sync {
|
||||||
returnValue = getRoomPreviewRoomIdOrAliasUnderlyingCallsCount
|
returnValue = getRoomPreviewFromRoomAliasRoomAliasUnderlyingCallsCount
|
||||||
}
|
}
|
||||||
|
|
||||||
return returnValue!
|
return returnValue!
|
||||||
@@ -1112,29 +1112,29 @@ class SDKClientMock: SDKClientProtocol {
|
|||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
if Thread.isMainThread {
|
if Thread.isMainThread {
|
||||||
getRoomPreviewRoomIdOrAliasUnderlyingCallsCount = newValue
|
getRoomPreviewFromRoomAliasRoomAliasUnderlyingCallsCount = newValue
|
||||||
} else {
|
} else {
|
||||||
DispatchQueue.main.sync {
|
DispatchQueue.main.sync {
|
||||||
getRoomPreviewRoomIdOrAliasUnderlyingCallsCount = newValue
|
getRoomPreviewFromRoomAliasRoomAliasUnderlyingCallsCount = newValue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public var getRoomPreviewRoomIdOrAliasCalled: Bool {
|
public var getRoomPreviewFromRoomAliasRoomAliasCalled: Bool {
|
||||||
return getRoomPreviewRoomIdOrAliasCallsCount > 0
|
return getRoomPreviewFromRoomAliasRoomAliasCallsCount > 0
|
||||||
}
|
}
|
||||||
public var getRoomPreviewRoomIdOrAliasReceivedRoomIdOrAlias: String?
|
public var getRoomPreviewFromRoomAliasRoomAliasReceivedRoomAlias: String?
|
||||||
public var getRoomPreviewRoomIdOrAliasReceivedInvocations: [String] = []
|
public var getRoomPreviewFromRoomAliasRoomAliasReceivedInvocations: [String] = []
|
||||||
|
|
||||||
var getRoomPreviewRoomIdOrAliasUnderlyingReturnValue: RoomPreview!
|
var getRoomPreviewFromRoomAliasRoomAliasUnderlyingReturnValue: RoomPreview!
|
||||||
public var getRoomPreviewRoomIdOrAliasReturnValue: RoomPreview! {
|
public var getRoomPreviewFromRoomAliasRoomAliasReturnValue: RoomPreview! {
|
||||||
get {
|
get {
|
||||||
if Thread.isMainThread {
|
if Thread.isMainThread {
|
||||||
return getRoomPreviewRoomIdOrAliasUnderlyingReturnValue
|
return getRoomPreviewFromRoomAliasRoomAliasUnderlyingReturnValue
|
||||||
} else {
|
} else {
|
||||||
var returnValue: RoomPreview? = nil
|
var returnValue: RoomPreview? = nil
|
||||||
DispatchQueue.main.sync {
|
DispatchQueue.main.sync {
|
||||||
returnValue = getRoomPreviewRoomIdOrAliasUnderlyingReturnValue
|
returnValue = getRoomPreviewFromRoomAliasRoomAliasUnderlyingReturnValue
|
||||||
}
|
}
|
||||||
|
|
||||||
return returnValue!
|
return returnValue!
|
||||||
@@ -1142,27 +1142,99 @@ class SDKClientMock: SDKClientProtocol {
|
|||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
if Thread.isMainThread {
|
if Thread.isMainThread {
|
||||||
getRoomPreviewRoomIdOrAliasUnderlyingReturnValue = newValue
|
getRoomPreviewFromRoomAliasRoomAliasUnderlyingReturnValue = newValue
|
||||||
} else {
|
} else {
|
||||||
DispatchQueue.main.sync {
|
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 {
|
public func getRoomPreviewFromRoomAlias(roomAlias: String) async throws -> RoomPreview {
|
||||||
if let error = getRoomPreviewRoomIdOrAliasThrowableError {
|
if let error = getRoomPreviewFromRoomAliasRoomAliasThrowableError {
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
getRoomPreviewRoomIdOrAliasCallsCount += 1
|
getRoomPreviewFromRoomAliasRoomAliasCallsCount += 1
|
||||||
getRoomPreviewRoomIdOrAliasReceivedRoomIdOrAlias = roomIdOrAlias
|
getRoomPreviewFromRoomAliasRoomAliasReceivedRoomAlias = roomAlias
|
||||||
getRoomPreviewRoomIdOrAliasReceivedInvocations.append(roomIdOrAlias)
|
getRoomPreviewFromRoomAliasRoomAliasReceivedInvocations.append(roomAlias)
|
||||||
if let getRoomPreviewRoomIdOrAliasClosure = getRoomPreviewRoomIdOrAliasClosure {
|
if let getRoomPreviewFromRoomAliasRoomAliasClosure = getRoomPreviewFromRoomAliasRoomAliasClosure {
|
||||||
return try await getRoomPreviewRoomIdOrAliasClosure(roomIdOrAlias)
|
return try await getRoomPreviewFromRoomAliasRoomAliasClosure(roomAlias)
|
||||||
} else {
|
} 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
|
//MARK: - getSessionVerificationController
|
||||||
|
|||||||
@@ -77,8 +77,7 @@ class JoinRoomScreenViewModel: JoinRoomScreenViewModelType, JoinRoomScreenViewMo
|
|||||||
hideLoadingIndicator()
|
hideLoadingIndicator()
|
||||||
}
|
}
|
||||||
|
|
||||||
// We need an SDK update to pass the via into this preview.
|
switch await clientProxy.roomPreviewForIdentifier(roomID, via: via) {
|
||||||
switch await clientProxy.roomPreviewForIdentifier(roomID) {
|
|
||||||
case .success(let roomDetails):
|
case .success(let roomDetails):
|
||||||
state.roomDetails = roomDetails
|
state.roomDetails = roomDetails
|
||||||
case .failure:
|
case .failure:
|
||||||
|
|||||||
@@ -148,9 +148,9 @@ struct JoinRoomScreen_Previews: PreviewProvider, TestablePreview {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if mode == .unknown {
|
if mode == .unknown {
|
||||||
clientProxy.roomPreviewForIdentifierReturnValue = .failure(.sdkError(ClientProxyMockError.generic))
|
clientProxy.roomPreviewForIdentifierViaReturnValue = .failure(.sdkError(ClientProxyMockError.generic))
|
||||||
} else {
|
} else {
|
||||||
clientProxy.roomPreviewForIdentifierReturnValue = .success(.init(roomID: "1",
|
clientProxy.roomPreviewForIdentifierViaReturnValue = .success(.init(roomID: "1",
|
||||||
name: "The Three-Body Problem - 三体",
|
name: "The Three-Body Problem - 三体",
|
||||||
canonicalAlias: "#3🌞problem:matrix.org",
|
canonicalAlias: "#3🌞problem:matrix.org",
|
||||||
// swiftlint:disable:next line_length
|
// swiftlint:disable:next line_length
|
||||||
|
|||||||
@@ -441,9 +441,9 @@ class ClientProxy: ClientProxyProtocol {
|
|||||||
room: room)
|
room: room)
|
||||||
}
|
}
|
||||||
|
|
||||||
func roomPreviewForIdentifier(_ identifier: String) async -> Result<RoomPreviewDetails, ClientProxyError> {
|
func roomPreviewForIdentifier(_ identifier: String, via: [String]) async -> Result<RoomPreviewDetails, ClientProxyError> {
|
||||||
do {
|
do {
|
||||||
let roomPreview = try await client.getRoomPreview(roomIdOrAlias: identifier)
|
let roomPreview = try await client.getRoomPreviewFromRoomId(roomId: identifier, viaServers: via)
|
||||||
return .success(.init(roomPreview))
|
return .success(.init(roomPreview))
|
||||||
} catch {
|
} catch {
|
||||||
MXLog.error("Failed retrieving preview for room: \(identifier) with error: \(error)")
|
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 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>
|
@discardableResult func loadUserDisplayName() async -> Result<Void, ClientProxyError>
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ struct RoomEventStringBuilder {
|
|||||||
return stateEventStringBuilder
|
return stateEventStringBuilder
|
||||||
.buildString(for: state, sender: sender, isOutgoing: isOutgoing)
|
.buildString(for: state, sender: sender, isOutgoing: isOutgoing)
|
||||||
.map(AttributedString.init)
|
.map(AttributedString.init)
|
||||||
case .roomMembership(let userID, let change):
|
case .roomMembership(let userID, _, let change):
|
||||||
return stateEventStringBuilder
|
return stateEventStringBuilder
|
||||||
.buildString(for: change, member: userID, sender: sender, isOutgoing: isOutgoing)
|
.buildString(for: change, member: userID, sender: sender, isOutgoing: isOutgoing)
|
||||||
.map(AttributedString.init)
|
.map(AttributedString.init)
|
||||||
|
|||||||
@@ -18,6 +18,12 @@ import Combine
|
|||||||
import Foundation
|
import Foundation
|
||||||
import MatrixRustSDK
|
import MatrixRustSDK
|
||||||
|
|
||||||
|
enum PaginationStatus {
|
||||||
|
case idle
|
||||||
|
case timelineEndReached
|
||||||
|
case paginating
|
||||||
|
}
|
||||||
|
|
||||||
struct PaginationState: Equatable {
|
struct PaginationState: Equatable {
|
||||||
static var `default` = PaginationState(backward: .idle, forward: .timelineEndReached)
|
static var `default` = PaginationState(backward: .idle, forward: .timelineEndReached)
|
||||||
let backward: PaginationStatus
|
let backward: PaginationStatus
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return buildStateTimelineItem(for: eventItemProxy, state: content, isOutgoing: isOutgoing)
|
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 {
|
if isDM, change == .joined, userID == self.userID {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,8 @@ final class TimelineProxy: TimelineProxyProtocol {
|
|||||||
// periphery:ignore - retaining purpose
|
// periphery:ignore - retaining purpose
|
||||||
private var timelineListener: RoomTimelineListener?
|
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 forwardPaginationStatusSubject = CurrentValueSubject<PaginationStatus, Never>(.timelineEndReached)
|
||||||
private let timelineUpdatesSubject = PassthroughSubject<[TimelineDiff], Never>()
|
private let timelineUpdatesSubject = PassthroughSubject<[TimelineDiff], Never>()
|
||||||
|
|
||||||
@@ -70,7 +71,15 @@ final class TimelineProxy: TimelineProxyProtocol {
|
|||||||
let result = await timeline.addListener(listener: timelineListener)
|
let result = await timeline.addListener(listener: timelineListener)
|
||||||
roomTimelineObservationToken = result.itemsStream
|
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)
|
.combineLatest(forwardPaginationStatusSubject)
|
||||||
.map { PaginationState(backward: $0.0, forward: $0.1) }
|
.map { PaginationState(backward: $0.0, forward: $0.1) }
|
||||||
.eraseToAnyPublisher()
|
.eraseToAnyPublisher()
|
||||||
@@ -144,9 +153,11 @@ final class TimelineProxy: TimelineProxyProtocol {
|
|||||||
MXLog.info("Paginating backwards")
|
MXLog.info("Paginating backwards")
|
||||||
|
|
||||||
do {
|
do {
|
||||||
_ = try await timeline.paginateBackwards(numEvents: requestSize)
|
let timelineEndReached = try await timeline.paginateBackwards(numEvents: requestSize)
|
||||||
MXLog.info("Finished paginating backwards")
|
MXLog.info("Finished paginating backwards")
|
||||||
|
|
||||||
|
backPaginationTimelineEndSubject.send(timelineEndReached)
|
||||||
|
|
||||||
return .success(())
|
return .success(())
|
||||||
} catch {
|
} catch {
|
||||||
MXLog.error("Failed paginating backwards with error: \(error)")
|
MXLog.error("Failed paginating backwards with error: \(error)")
|
||||||
@@ -166,7 +177,7 @@ final class TimelineProxy: TimelineProxyProtocol {
|
|||||||
forwardPaginationStatusSubject.send(.paginating)
|
forwardPaginationStatusSubject.send(.paginating)
|
||||||
|
|
||||||
do {
|
do {
|
||||||
let timelineEndReached = try await timeline.focusedPaginateForwards(numEvents: 16)
|
let timelineEndReached = try await timeline.focusedPaginateForwards(numEvents: requestSize)
|
||||||
MXLog.info("Finished paginating forwards")
|
MXLog.info("Finished paginating forwards")
|
||||||
|
|
||||||
forwardPaginationStatusSubject.send(timelineEndReached ? .timelineEndReached : .idle)
|
forwardPaginationStatusSubject.send(timelineEndReached ? .timelineEndReached : .idle)
|
||||||
@@ -536,7 +547,16 @@ final class TimelineProxy: TimelineProxyProtocol {
|
|||||||
|
|
||||||
private func subscribeToPagination() {
|
private func subscribeToPagination() {
|
||||||
let backPaginationListener = RoomPaginationStatusListener { [weak self] status in
|
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 {
|
do {
|
||||||
backPaginationStatusObservationToken = try timeline.subscribeToBackPaginationStatus(listener: backPaginationListener)
|
backPaginationStatusObservationToken = try timeline.subscribeToBackPaginationStatus(listener: backPaginationListener)
|
||||||
@@ -562,13 +582,13 @@ private final class RoomTimelineListener: TimelineListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private final class RoomPaginationStatusListener: PaginationStatusListener {
|
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
|
self.onUpdateClosure = onUpdateClosure
|
||||||
}
|
}
|
||||||
|
|
||||||
func onUpdate(status: PaginationStatus) {
|
func onUpdate(status: PaginatorState) {
|
||||||
onUpdateClosure(status)
|
onUpdateClosure(status)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ class JoinRoomScreenViewModelTests: XCTestCase {
|
|||||||
|
|
||||||
clientProxy.joinRoomViaReturnValue = throwing ? .failure(.sdkError(ClientProxyMockError.generic)) : .success(())
|
clientProxy.joinRoomViaReturnValue = throwing ? .failure(.sdkError(ClientProxyMockError.generic)) : .success(())
|
||||||
|
|
||||||
clientProxy.roomPreviewForIdentifierReturnValue = .success(.init(roomID: "",
|
clientProxy.roomPreviewForIdentifierViaReturnValue = .success(.init(roomID: "",
|
||||||
name: nil,
|
name: nil,
|
||||||
canonicalAlias: nil,
|
canonicalAlias: nil,
|
||||||
topic: nil,
|
topic: nil,
|
||||||
|
|||||||
@@ -272,7 +272,7 @@ class RoomFlowCoordinatorTests: XCTestCase {
|
|||||||
clientProxy = ClientProxyMock(.init(userID: "hi@bob", roomSummaryProvider: RoomSummaryProviderMock(.init(state: .loaded(.mockRooms)))))
|
clientProxy = ClientProxyMock(.init(userID: "hi@bob", roomSummaryProvider: RoomSummaryProviderMock(.init(state: .loaded(.mockRooms)))))
|
||||||
timelineControllerFactory = RoomTimelineControllerFactoryMock(configuration: .init())
|
timelineControllerFactory = RoomTimelineControllerFactoryMock(configuration: .init())
|
||||||
|
|
||||||
clientProxy.roomPreviewForIdentifierClosure = { [roomType] roomID in
|
clientProxy.roomPreviewForIdentifierViaClosure = { [roomType] roomID, _ in
|
||||||
switch roomType {
|
switch roomType {
|
||||||
case .invited:
|
case .invited:
|
||||||
return .success(.init(roomID: roomID,
|
return .success(.init(roomID: roomID,
|
||||||
|
|||||||
+1
-1
@@ -49,7 +49,7 @@ packages:
|
|||||||
# Element/Matrix dependencies
|
# Element/Matrix dependencies
|
||||||
MatrixRustSDK:
|
MatrixRustSDK:
|
||||||
url: https://github.com/element-hq/matrix-rust-components-swift
|
url: https://github.com/element-hq/matrix-rust-components-swift
|
||||||
exactVersion: 1.0.0
|
exactVersion: 1.0.1
|
||||||
# path: ../matrix-rust-sdk
|
# path: ../matrix-rust-sdk
|
||||||
Compound:
|
Compound:
|
||||||
url: https://github.com/element-hq/compound-ios
|
url: https://github.com/element-hq/compound-ios
|
||||||
|
|||||||
Reference in New Issue
Block a user