@@ -10,25 +10,29 @@ import SwiftUI
1010// MARK: - Configuration Actions
1111
1212extension AddTaskView {
13- func addConfig( ) {
13+ @MainActor
14+ func addConfig( ) async -> Bool {
1415 let profile = rsyncUIdata. profile
15- Task { @MainActor in
16- rsyncUIdata. configurations = await newdata. addConfig ( profile, rsyncUIdata. configurations)
17- if SharedReference . shared. duplicatecheck {
18- if let configurations = rsyncUIdata. configurations {
19- VerifyDuplicates ( configurations)
20- }
16+ let beforeCount = rsyncUIdata. configurations? . count ?? 0
17+ rsyncUIdata. configurations = await newdata. addConfig ( profile, rsyncUIdata. configurations)
18+ if SharedReference . shared. duplicatecheck {
19+ if let configurations = rsyncUIdata. configurations {
20+ VerifyDuplicates ( configurations)
2121 }
2222 }
23+ return ( rsyncUIdata. configurations? . count ?? 0 ) > beforeCount
2324 }
2425
25- func validateAndUpdate( ) {
26+ @MainActor
27+ func validateAndUpdate( ) async -> Bool {
2628 let profile = rsyncUIdata. profile
27- Task { @MainActor in
28- rsyncUIdata. configurations = await newdata. updateConfig ( profile, rsyncUIdata. configurations)
29- // Reset after Update
29+ let selectedHiddenID = newdata. selectedconfig? . hiddenID
30+ rsyncUIdata. configurations = await newdata. updateConfig ( profile, rsyncUIdata. configurations)
31+ let didUpdate = selectedHiddenID != nil && newdata. selectedconfig == nil
32+ if didUpdate {
3033 clearSelection ( )
3134 }
35+ return didUpdate
3236 }
3337}
3438
@@ -37,7 +41,9 @@ extension AddTaskView {
3741extension AddTaskView {
3842 var updateButton : some View {
3943 ConditionalGlassButton ( systemImage: " arrow.down " , text: " Update " , helpText: " Update task " ) {
40- validateAndUpdate ( )
44+ Task { @MainActor in
45+ _ = await validateAndUpdate ( )
46+ }
4147 }
4248 }
4349
0 commit comments