mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
Security and privacy part 2 (#3637)
* handling the history visibility flag * better logic to handle visibility * better handling of the visibility options state * added some copies, and the public room directory visibility state * completed the UI added also the preview tests * improved the handling of the directory visibility * added the space users case and improved handling of the access -> vsibility reaction. Also added a simple error handling for the public directory toggle * added the edit room address view but is missing its full implementation * implement the UI for the edit room address screen * implemented error checking when editing the address * updated preview tests and improved code * typo fix * Fix various issues after rebasing. * Fix build errors and broken snapshot tests * Adopt latest room privacy and canonical alias setting APIs * Add support for creating and editing the room's alias. * Add support for saving room privacy setting changes. * Fix room alias screen snapshot tests following recent changes. --------- Co-authored-by: Stefan Ceriu <stefanc@matrix.org>
This commit is contained in:
+49
-7
@@ -8,21 +8,44 @@
|
||||
import Foundation
|
||||
|
||||
enum SecurityAndPrivacyScreenViewModelAction {
|
||||
case done
|
||||
case displayEditAddressScreen
|
||||
}
|
||||
|
||||
struct SecurityAndPrivacyScreenViewState: BindableState {
|
||||
var bindings: SecurityAndPrivacyScreenViewStateBindings
|
||||
|
||||
let serverName: String
|
||||
var currentSettings: SecurityAndPrivacySettings
|
||||
var bindings: SecurityAndPrivacyScreenViewStateBindings
|
||||
var canonicalAlias: String?
|
||||
|
||||
var hasChanges: Bool {
|
||||
private var hasChanges: Bool {
|
||||
currentSettings != bindings.desiredSettings
|
||||
}
|
||||
|
||||
init(accessType: SecurityAndPrivacyRoomAccessType,
|
||||
isEncryptionEnabled: Bool) {
|
||||
let settings = SecurityAndPrivacySettings(accessType: accessType, isEncryptionEnabled: isEncryptionEnabled)
|
||||
var isSaveDisabled: Bool {
|
||||
!hasChanges ||
|
||||
(currentSettings.isVisibileInRoomDirectory == nil &&
|
||||
bindings.desiredSettings.accessType != .inviteOnly &&
|
||||
canonicalAlias != nil)
|
||||
}
|
||||
|
||||
var availableVisibilityOptions: [SecurityAndPrivacyHistoryVisibility] {
|
||||
var options = [SecurityAndPrivacyHistoryVisibility.sinceSelection]
|
||||
if !bindings.desiredSettings.isEncryptionEnabled, bindings.desiredSettings.accessType == .anyone {
|
||||
options.append(.anyone)
|
||||
} else {
|
||||
options.append(.sinceInvite)
|
||||
}
|
||||
return options
|
||||
}
|
||||
|
||||
init(serverName: String,
|
||||
accessType: SecurityAndPrivacyRoomAccessType,
|
||||
isEncryptionEnabled: Bool,
|
||||
historyVisibility: SecurityAndPrivacyHistoryVisibility) {
|
||||
self.serverName = serverName
|
||||
let settings = SecurityAndPrivacySettings(accessType: accessType,
|
||||
isEncryptionEnabled: isEncryptionEnabled,
|
||||
historyVisibility: historyVisibility)
|
||||
currentSettings = settings
|
||||
bindings = SecurityAndPrivacyScreenViewStateBindings(desiredSettings: settings)
|
||||
}
|
||||
@@ -36,12 +59,15 @@ struct SecurityAndPrivacyScreenViewStateBindings {
|
||||
struct SecurityAndPrivacySettings: Equatable {
|
||||
var accessType: SecurityAndPrivacyRoomAccessType
|
||||
var isEncryptionEnabled: Bool
|
||||
var historyVisibility: SecurityAndPrivacyHistoryVisibility
|
||||
var isVisibileInRoomDirectory: Bool?
|
||||
}
|
||||
|
||||
enum SecurityAndPrivacyRoomAccessType {
|
||||
case inviteOnly
|
||||
case askToJoin
|
||||
case anyone
|
||||
case spaceUsers
|
||||
}
|
||||
|
||||
enum SecurityAndPrivacyAlertType {
|
||||
@@ -51,4 +77,20 @@ enum SecurityAndPrivacyAlertType {
|
||||
enum SecurityAndPrivacyScreenViewAction {
|
||||
case save
|
||||
case tryUpdatingEncryption(Bool)
|
||||
case editAddress
|
||||
}
|
||||
|
||||
enum SecurityAndPrivacyHistoryVisibility {
|
||||
case sinceSelection
|
||||
case sinceInvite
|
||||
case anyone
|
||||
|
||||
var fallbackOption: Self {
|
||||
switch self {
|
||||
case .sinceInvite, .sinceSelection:
|
||||
return .sinceSelection
|
||||
case .anyone:
|
||||
return .sinceInvite
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user