Skip to content

Commit a46a00a

Browse files
committed
update
1 parent a993407 commit a46a00a

4 files changed

Lines changed: 37 additions & 18 deletions

File tree

RsyncUI/Model/Global/SharedReference.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ final class SharedReference {
5050
/// A safety rule
5151
@ObservationIgnored var confirmexecute: Bool = false
5252
/// Duplicatecheck
53-
@ObservationIgnored var duplicatecheck: Bool = false
53+
@ObservationIgnored var duplicatecheck: Bool = true
5454
/// New version of RsyncUI discovered
5555
@ObservationIgnored var newversion: Bool = false
5656
/// Synchronize without timedelay URL-actions

RsyncUI/Views/InspectorViews/Add/extensionAddTaskView+BusinessLogic.swift

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,20 @@ extension AddTaskView {
2525
case .localcatalogField: focusField = .remotecatalogField
2626
case .remotecatalogField: focusField = .remoteuserField
2727
case .remoteuserField: focusField = .remoteserverField
28-
case .snapshotnumField: validateAndUpdate()
28+
case .snapshotnumField:
29+
Task { @MainActor in
30+
_ = await validateAndUpdate()
31+
}
2932
case .remoteserverField:
30-
if newdata.selectedconfig == nil { addConfig() } else { validateAndUpdate() }
33+
if newdata.selectedconfig == nil {
34+
Task { @MainActor in
35+
_ = await addConfig()
36+
}
37+
} else {
38+
Task { @MainActor in
39+
_ = await validateAndUpdate()
40+
}
41+
}
3142
focusField = nil
3243
default: return
3344
}

RsyncUI/Views/InspectorViews/Add/extensionAddTaskView+ViewBuilders.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ extension AddTaskView {
3838
ConditionalGlassButton(systemImage: "plus",
3939
text: "Add",
4040
helpText: "Add task") {
41-
addConfig()
42-
showAddPopover = false
43-
newdata.resetForm()
41+
Task { @MainActor in
42+
if await addConfig() {
43+
showAddPopover = false
44+
}
45+
}
4446
}
4547

4648
Spacer()

RsyncUI/Views/InspectorViews/Add/extensionAddTaskView.swift

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,29 @@ import SwiftUI
1010
// MARK: - Configuration Actions
1111

1212
extension 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 {
3741
extension 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

Comments
 (0)