mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
06f37dacae
* Remove the protocol for SpaceServiceRoom given its a struct type. * Fix a few missed mocks in the unit tests.
45 lines
1.2 KiB
Swift
45 lines
1.2 KiB
Swift
//
|
|
// Copyright 2025 Element Creations 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
|
|
|
|
enum ManageAuthorizedSpacesScreenViewModelAction {
|
|
case dismiss
|
|
}
|
|
|
|
struct ManageAuthorizedSpacesScreenViewState: BindableState {
|
|
let authorizedSpacesSelection: AuthorizedSpacesSelection
|
|
var selectedIDs: Set<String>
|
|
|
|
var hasChanges: Bool {
|
|
authorizedSpacesSelection.initialSelectedIDs != selectedIDs
|
|
}
|
|
|
|
var isDoneButtonDisabled: Bool {
|
|
selectedIDs.isEmpty || !hasChanges
|
|
}
|
|
|
|
init(authorizedSpacesSelection: AuthorizedSpacesSelection) {
|
|
self.authorizedSpacesSelection = authorizedSpacesSelection
|
|
selectedIDs = authorizedSpacesSelection.initialSelectedIDs
|
|
}
|
|
}
|
|
|
|
enum ManageAuthorizedSpacesScreenViewAction {
|
|
case cancel
|
|
case done
|
|
case toggle(spaceID: String)
|
|
}
|
|
|
|
struct AuthorizedSpacesSelection {
|
|
let joinedSpaces: [SpaceServiceRoom]
|
|
let unknownSpacesIDs: [String]
|
|
let initialSelectedIDs: Set<String>
|
|
let selectedIDs: PassthroughSubject<Set<String>, Never> = .init()
|
|
}
|