Files
element-x-ios/ElementX/Sources/Mocks/InvitedRoomProxyMock.swift
T
Stefan Ceriu 07e96115ce SDK update (#3891)
* Bump the RustSDK to v25.03.11

* Replace oidc login prompt with nil following the changes from https://github.com/matrix-org/matrix-rust-sdk/pull/4761

```
/// * `prompt` - The desired user experience in the web UI. No value means
///   that the user wishes to login into an existing account, and a value of
///   `Create` means that the user wishes to register a new account.
```

* Fix trailing closure warnings

* Update the client proxy after making `getNotificationSettings()` and  `cachedAvatarUrl()` async (they used to be blocking on the rust side).

* Move `Room.isEncrypted` to the info publisher and manually update the encryption state when creating the room.

* Bump the SDK again to v25.03.12 - This introduces a new way to configure the tokio runtime that we can use to have extensions use less memory
- introduce a new Target struct that takes care of setting up rust services (tracing and tokio) for our various targets
- cleanup MXLog and friends

* Address PR comments

* Bump the SDK again, switch back to using `.consent` as the OIDC login prompt (which was reintroduced in matrix-org/matrix-rust-sdk/pull/4791)
2025-03-13 11:17:37 +02:00

85 lines
3.1 KiB
Swift

//
// Copyright 2024 New Vector Ltd.
//
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
// Please see LICENSE files in the repository root for full details.
//
import Combine
import Foundation
import MatrixRustSDK
@MainActor
struct InvitedRoomProxyMockConfiguration {
var id = UUID().uuidString
var name: String?
var avatarURL: URL?
var members: [RoomMemberProxyMock] = .allMembers
var inviter: RoomMemberProxyMock = .mockAlice
}
extension InvitedRoomProxyMock {
@MainActor
convenience init(_ configuration: InvitedRoomProxyMockConfiguration) {
self.init()
id = configuration.id
inviter = configuration.inviter
info = RoomInfoProxy(roomInfo: .init(configuration))
rejectInvitationReturnValue = .success(())
}
}
extension RoomInfo {
@MainActor init(_ configuration: InvitedRoomProxyMockConfiguration) {
self.init(id: configuration.id,
encryptionState: .notEncrypted,
creator: nil,
displayName: configuration.name,
rawName: nil,
topic: nil,
avatarUrl: configuration.avatarURL?.absoluteString,
isDirect: false,
isPublic: false,
isSpace: false,
isTombstoned: false,
isFavourite: false,
canonicalAlias: nil,
alternativeAliases: [],
membership: .knocked,
inviter: .init(configuration.inviter),
heroes: [],
activeMembersCount: UInt64(configuration.members.filter { $0.membership == .join || $0.membership == .invite }.count),
invitedMembersCount: UInt64(configuration.members.filter { $0.membership == .invite }.count),
joinedMembersCount: UInt64(configuration.members.filter { $0.membership == .join }.count),
userPowerLevels: [:],
highlightCount: 0,
notificationCount: 0,
cachedUserDefinedNotificationMode: nil,
hasRoomCall: false,
activeRoomCallParticipants: [],
isMarkedUnread: false,
numUnreadMessages: 0,
numUnreadNotifications: 0,
numUnreadMentions: 0,
pinnedEventIds: [],
joinRule: .invite,
historyVisibility: .shared)
}
}
private extension RoomMember {
init(_ proxy: RoomMemberProxyProtocol) {
self.init(userId: proxy.userID,
displayName: proxy.displayName,
avatarUrl: proxy.avatarURL?.absoluteString,
membership: proxy.membership,
isNameAmbiguous: proxy.disambiguatedDisplayName != proxy.displayName,
powerLevel: Int64(proxy.powerLevel),
normalizedPowerLevel: Int64(proxy.powerLevel),
isIgnored: proxy.isIgnored,
suggestedRoleForPowerLevel: proxy.role,
membershipChangeReason: proxy.membershipChangeReason)
}
}