Tunnel view model: No need to save if we already have a validated configuration object
Signed-off-by: Roopesh Chander <roop@roopc.net>
This commit is contained in:
@@ -96,6 +96,10 @@ class TunnelViewModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func save() -> SaveResult<InterfaceConfiguration> {
|
func save() -> SaveResult<InterfaceConfiguration> {
|
||||||
|
if let validatedConfiguration = validatedConfiguration {
|
||||||
|
// It's already validated and saved
|
||||||
|
return .saved(validatedConfiguration)
|
||||||
|
}
|
||||||
fieldsWithError.removeAll()
|
fieldsWithError.removeAll()
|
||||||
guard let name = scratchpad[.name]?.trimmingCharacters(in: .whitespacesAndNewlines), (!name.isEmpty) else {
|
guard let name = scratchpad[.name]?.trimmingCharacters(in: .whitespacesAndNewlines), (!name.isEmpty) else {
|
||||||
fieldsWithError.insert(.name)
|
fieldsWithError.insert(.name)
|
||||||
@@ -234,6 +238,10 @@ class TunnelViewModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func save() -> SaveResult<PeerConfiguration> {
|
func save() -> SaveResult<PeerConfiguration> {
|
||||||
|
if let validatedConfiguration = validatedConfiguration {
|
||||||
|
// It's already validated and saved
|
||||||
|
return .saved(validatedConfiguration)
|
||||||
|
}
|
||||||
fieldsWithError.removeAll()
|
fieldsWithError.removeAll()
|
||||||
guard let publicKeyString = scratchpad[.publicKey] else {
|
guard let publicKeyString = scratchpad[.publicKey] else {
|
||||||
fieldsWithError.insert(.publicKey)
|
fieldsWithError.insert(.publicKey)
|
||||||
|
|||||||
Reference in New Issue
Block a user