Skip to content

Commit 351c325

Browse files
authored
Merge pull request #228 from TaskarCenterAtUW/fix-submission-apierror-result
fix
2 parents b1da45a + 0365be3 commit 351c325

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

GoInfoGame/GoInfoGame/quests/QuestProtocols.swift

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,21 @@ class QuestBase {
5252
MapViewPublisher.shared.dismissSheet.send(.syncing)
5353

5454
DatasyncManager.shared.syncDataToOSM { success in
55-
print("SYNC DONE: \(success ? "Success" : "Failed")")
5655
DispatchQueue.main.async {
5756
MapViewPublisher.shared.dismissSheet.send(.synced)
58-
if success {
59-
MapViewPublisher.shared.dismissSheet.send(.submitted(storedId))
60-
} else {
61-
print("Sync failed. Handle accordingly.")
62-
MapViewPublisher.shared.dismissSheet.send(.failed("Submission failed. Please try again."))
57+
58+
switch success {
59+
case .success(let success):
60+
if success {
61+
MapViewPublisher.shared.dismissSheet.send(.submitted(storedId))
62+
} else {
63+
print("Sync failed. Handle accordingly.")
64+
MapViewPublisher.shared.dismissSheet.send(.failed("Submission failed. Please try again."))
65+
}
66+
case .failure(let error):
67+
print("Error during sync: \(error)")
68+
let errorMessage = error.localizedDescription
69+
MapViewPublisher.shared.dismissSheet.send(.failed(errorMessage))
6370
}
6471
}
6572
}

0 commit comments

Comments
 (0)