mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
updated existing preview tests and added a test for the single space cases
fixed a bug where was not possible to re-select the space members option with unknown spaces. pr suggestions
This commit is contained in:
+2
-10
@@ -7,7 +7,6 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import MatrixRustSDK
|
||||
|
||||
enum SecurityAndPrivacyScreenViewModelAction {
|
||||
case displayEditAddressScreen
|
||||
@@ -39,14 +38,11 @@ struct SecurityAndPrivacyScreenViewState: BindableState {
|
||||
var canEditHistoryVisibility = false
|
||||
var joinedParentSpaces: [SpaceRoomProxyProtocol] = []
|
||||
|
||||
/// The count of the intersection between the set of joined parent spaces and the set of spaces in the current access type
|
||||
var selectableSpacesCount: Int {
|
||||
Set(joinedParentSpaces.map(\.id) + currentSettings.accessType.spaceIDs).count
|
||||
}
|
||||
|
||||
private var desiredJoinedParentSpaces: [SpaceRoomProxyProtocol] {
|
||||
joinedParentSpaces.filter { bindings.desiredSettings.accessType.spaceIDs.contains($0.id) }
|
||||
}
|
||||
|
||||
private var hasChanges: Bool {
|
||||
currentSettings != bindings.desiredSettings
|
||||
}
|
||||
@@ -111,13 +107,9 @@ struct SecurityAndPrivacyScreenViewState: BindableState {
|
||||
var spaceSelection: SpaceSelection {
|
||||
if selectableSpacesCount > 1 {
|
||||
.multiple
|
||||
} else if let desiredJoinedParent = desiredJoinedParentSpaces.first {
|
||||
// The parent space is joined by the user and is also currently selected
|
||||
.singleJoined(desiredJoinedParent)
|
||||
} else if let joinedParent = joinedParentSpaces.first {
|
||||
// The parent space is joined by the user but is not currently selected
|
||||
.singleJoined(joinedParent)
|
||||
} else if let unknownSpaceID = bindings.desiredSettings.accessType.spaceIDs.first {
|
||||
} else if let unknownSpaceID = currentSettings.accessType.spaceIDs.first {
|
||||
// The space is not joined by the user but is currently selected
|
||||
.singleUnknown(id: unknownSpaceID)
|
||||
} else {
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ class SecurityAndPrivacyScreenViewModel: SecurityAndPrivacyScreenViewModelType,
|
||||
setupRoomDirectoryVisibility()
|
||||
setupSubscriptions()
|
||||
Task {
|
||||
switch await clientProxy.spaceService.joinedParents(roomID: roomProxy.id) {
|
||||
switch await clientProxy.spaceService.joinedParents(childID: roomProxy.id) {
|
||||
case .success(let joinedParentSpaces):
|
||||
state.joinedParentSpaces = joinedParentSpaces
|
||||
case .failure:
|
||||
|
||||
+2
-2
@@ -242,7 +242,7 @@ struct SecurityAndPrivacyScreen_Previews: PreviewProvider, TestablePreview {
|
||||
clientProxy: ClientProxyMock(.init(userIDServerName: "matrix.org",
|
||||
spaceServiceConfiguration: .init(joinedParentSpaces: [space]))),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
appSettings: AppSettings())
|
||||
appSettings: appSettings)
|
||||
}()
|
||||
|
||||
static let multipleSpacesMembersViewModel = {
|
||||
@@ -259,7 +259,7 @@ struct SecurityAndPrivacyScreen_Previews: PreviewProvider, TestablePreview {
|
||||
clientProxy: ClientProxyMock(.init(userIDServerName: "matrix.org",
|
||||
spaceServiceConfiguration: .init(joinedParentSpaces: spaces))),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
appSettings: AppSettings())
|
||||
appSettings: appSettings)
|
||||
}()
|
||||
|
||||
static let askToJoinViewModel = {
|
||||
|
||||
Reference in New Issue
Block a user