Simplify a few things of CopySavingButton
- Make saving handler more readable - Drop unnecessary protocol
This commit is contained in:
parent
ddce671c62
commit
c88dfc28c4
|
@ -25,11 +25,7 @@
|
|||
|
||||
import SwiftUI
|
||||
|
||||
protocol CopySavingModel: Equatable {
|
||||
init()
|
||||
}
|
||||
|
||||
struct CopySavingButton<T: CopySavingModel, Label: View>: View {
|
||||
struct CopySavingButton<T: Equatable, Label: View>: View {
|
||||
@Binding var original: T
|
||||
|
||||
@Binding var copy: T
|
||||
|
@ -69,12 +65,9 @@ struct CopySavingButton<T: CopySavingModel, Label: View>: View {
|
|||
}
|
||||
|
||||
private func saveToOriginal() {
|
||||
defer {
|
||||
onSave?()
|
||||
if copy != original {
|
||||
original = copy
|
||||
}
|
||||
guard copy != original else {
|
||||
return
|
||||
}
|
||||
original = copy
|
||||
onSave?()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,9 +26,6 @@
|
|||
import SwiftUI
|
||||
import PassepartoutCore
|
||||
|
||||
extension Profile.Account: CopySavingModel {
|
||||
}
|
||||
|
||||
struct AccountView: View {
|
||||
@ObservedObject private var providerManager: ProviderManager
|
||||
|
||||
|
|
|
@ -26,9 +26,6 @@
|
|||
import SwiftUI
|
||||
import PassepartoutCore
|
||||
|
||||
extension Profile.NetworkSettings: CopySavingModel {
|
||||
}
|
||||
|
||||
struct NetworkSettingsView: View {
|
||||
@ObservedObject private var currentProfile: ObservableProfile
|
||||
|
||||
|
|
|
@ -26,9 +26,6 @@
|
|||
import SwiftUI
|
||||
import PassepartoutCore
|
||||
|
||||
extension Profile.OnDemand: CopySavingModel {
|
||||
}
|
||||
|
||||
struct OnDemandView: View {
|
||||
@ObservedObject private var productManager: ProductManager
|
||||
|
||||
|
|
Loading…
Reference in New Issue