Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump SDK #2857

Merged
merged 6 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ElementX.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7308,7 +7308,7 @@
repositoryURL = "https://github.com/element-hq/matrix-rust-components-swift";
requirement = {
kind = exactVersion;
version = 1.0.0;
version = 1.0.1;
};
};
701C7BEF8F70F7A83E852DCC /* XCRemoteSwiftPackageReference "GZIP" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/element-hq/matrix-rust-components-swift",
"state" : {
"revision" : "7437bbf102fb5dafb4e61aad6b9aa43dc34db0cc",
"version" : "1.0.0"
"revision" : "dfd7a1e7ad140e3c3e186301a20a53a6628f1bb8",
"version" : "1.0.1"
}
},
{
Expand Down
48 changes: 24 additions & 24 deletions ElementX/Sources/Mocks/Generated/GeneratedMocks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2632,70 +2632,70 @@ 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!
}
}
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!
}
}
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
Expand Down
126 changes: 99 additions & 27 deletions ElementX/Sources/Mocks/Generated/SDKGeneratedMocks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1093,76 +1093,148 @@ 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!
}
}
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!
}
}
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
26 changes: 13 additions & 13 deletions ElementX/Sources/Screens/JoinRoomScreen/View/JoinRoomScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions ElementX/Sources/Services/Client/ClientProxy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ import Combine
import Foundation
import MatrixRustSDK

enum PaginationStatus {
Velin92 marked this conversation as resolved.
Show resolved Hide resolved
case idle
case timelineEndReached
case paginating
}

struct PaginationState: Equatable {
static var `default` = PaginationState(backward: .idle, forward: .timelineEndReached)
let backward: PaginationStatus
Expand Down
Loading
Loading