Skip to content

Commit 4211217

Browse files
author
Achyut Kumar M
committed
modify closure and sync success logic
1 parent c629bda commit 4211217

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

GoInfoGame/GoInfoGame/quests/QuestProtocols.swift

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,9 @@ class QuestBase {
4141

4242
public func updateTags(id: Int64, tags:[String:String], type: ElementType, isUndo: Bool = false) {
4343

44-
if MapUndoManager.shared.updateTagsHandler == nil {
45-
MapUndoManager.shared.updateTagsHandler = { [weak self] id, tags, type in
46-
self?.updateTags(id: id, tags: tags, type: type, isUndo: true)
47-
}
48-
}
44+
MapUndoManager.shared.updateTagsHandler = { [weak self] id, tags, type in
45+
self?.updateTags(id: id, tags: tags, type: type)
46+
}
4947

5048

5149
// Convert from ElementType enum to StoredElementEnum
@@ -75,18 +73,14 @@ class QuestBase {
7573
switch success {
7674
case .success(let success):
7775
if success {
78-
if let elementSubmittingToPOSM = self.elementSubmittingToPOSM {
79-
switch elementSubmittingToPOSM {
80-
case .node:
81-
print("Node submitted successfully")
82-
_ = DatabaseConnector.shared.addNodeTags(id: storedId, tags: ["ext:gig_complete" : "yes"])
83-
case .way:
84-
print("Way submitted successfully")
85-
_ = DatabaseConnector.shared.addWayTags(id: storedId, tags: ["ext:gig_complete" : "yes"])
86-
}
76+
if MapUndoManager.shared.isUndoInProgress {
77+
MapUndoManager.shared.finalizeSuccessfulSubmit(id: Int(id), type: type)
78+
MapUndoManager.shared.isUndoInProgress = false
8779
}
88-
MapViewPublisher.shared.dismissSheet.send(.submitted(storedId))
89-
} else {
80+
81+
MapViewPublisher.shared.dismissSheet.send(.submitted("\(id)"))
82+
}
83+
else {
9084
print("Sync failed. Handle accordingly.")
9185
MapViewPublisher.shared.dismissSheet.send(.failed("Submission failed. Please try again."))
9286
}

0 commit comments

Comments
 (0)