Files
letro-ios/ElementX/Sources/Mocks/KnockedRoomProxyMock.swift
Stefan Ceriu e5a49c568f Adopt room info power levels (#4245)
* Use the newly RoomInfo published PowerLevels; update permissions at the same time as the room info and avoid unnecessary async calls.

* Introduce a RoomInfoProxyProtocol and associated mock and move away from mocked SDK RoomInfos

* Bump the SDK to v25.06.23

* Expose new non-throwing methods for checking one's own user permissions

* Fix the unit and preview tests (except the TimelineMediaPreviewDetails for which simplified snapshots were generated)

* Converge on one single implementation for computing a room's avatar.

* Fix more unit tests

* Fix the TimelineMediaPreviewDetailsView snapshot tests

This reverts commit 9b6c819e611ad2fa3de2c34a4a7aa556fc9faadd.

---------

Co-authored-by: Doug <douglase@element.io>
2025-06-24 17:48:00 +01:00

71 lines
2.0 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 KnockedRoomProxyMockConfiguration {
var id = UUID().uuidString
var name: String?
var avatarURL: URL?
var members: [RoomMemberProxyMock] = .allMembers
}
extension KnockedRoomProxyMock {
@MainActor
convenience init(_ configuration: KnockedRoomProxyMockConfiguration) {
self.init()
id = configuration.id
info = RoomInfoProxyMock(configuration)
}
}
extension RoomInfoProxyMock {
@MainActor convenience init(_ configuration: KnockedRoomProxyMockConfiguration) {
self.init()
id = configuration.id
isEncrypted = false
creator = nil
displayName = configuration.name
rawName = nil
topic = nil
avatarURL = configuration.avatarURL
isDirect = false
isPublic = false
isSpace = false
successor = nil
isFavourite = false
canonicalAlias = nil
alternativeAliases = []
membership = .knocked
inviter = nil
heroes = []
activeMembersCount = configuration.members.filter { $0.membership == .join || $0.membership == .invite }.count
invitedMembersCount = configuration.members.filter { $0.membership == .invite }.count
joinedMembersCount = configuration.members.filter { $0.membership == .join }.count
highlightCount = 0
notificationCount = 0
cachedUserDefinedNotificationMode = nil
hasRoomCall = false
activeRoomCallParticipants = []
isMarkedUnread = false
unreadMessagesCount = 0
unreadNotificationsCount = 0
unreadMentionsCount = 0
pinnedEventIDs = []
joinRule = .knock
historyVisibility = .shared
powerLevels = RoomPowerLevelsProxyMock(configuration: .init())
}
}