Skip to content

Commit 5b28ee5

Browse files
authored
Merge pull request #234 from TaskarCenterAtUW/fix-refresh-quests-db
add enum to update gig_complete tag after successful submission
2 parents 52077d1 + c1ee817 commit 5b28ee5

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

GoInfoGame/GoInfoGame/quests/QuestProtocols.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ import SwiftUI
1111
import osmparser
1212
import MapKit
1313

14+
enum ElementSubmittingToPOSM {
15+
case node, way
16+
}
17+
1418
protocol Quest {
1519
associatedtype AnswerClass // The class that represents answer
1620
var title:String {get}
@@ -30,6 +34,9 @@ protocol Quest {
3034

3135
class QuestBase {
3236
public var internalForm: (any QuestForm)? = nil
37+
38+
private var elementSubmittingToPOSM: ElementSubmittingToPOSM?
39+
3340
// Add a custom implementation
3441

3542
public func updateTags(id: Int64, tags:[String:String], type: ElementType){
@@ -40,8 +47,10 @@ class QuestBase {
4047
_ = DatabaseConnector.shared.createChangeset(id: storedId, type: storedElementType, tags: tags)
4148
switch (storedElementType){
4249
case .way:
50+
elementSubmittingToPOSM = .way
4351
_ = DatabaseConnector.shared.addWayTags(id: storedId, tags: tags)
4452
case .node:
53+
elementSubmittingToPOSM = .node
4554
_ = DatabaseConnector.shared.addNodeTags(id: storedId, tags: tags)
4655
case .unknown:
4756
print("Unknown Stored element type received")
@@ -58,6 +67,16 @@ class QuestBase {
5867
switch success {
5968
case .success(let success):
6069
if success {
70+
if let elementSubmittingToPOSM = self.elementSubmittingToPOSM {
71+
switch elementSubmittingToPOSM {
72+
case .node:
73+
print("Node submitted successfully")
74+
_ = DatabaseConnector.shared.addNodeTags(id: storedId, tags: ["ext:gig_complete" : "yes"])
75+
case .way:
76+
print("Way submitted successfully")
77+
_ = DatabaseConnector.shared.addWayTags(id: storedId, tags: ["ext:gig_complete" : "yes"])
78+
}
79+
}
6180
MapViewPublisher.shared.dismissSheet.send(.submitted(storedId))
6281
} else {
6382
print("Sync failed. Handle accordingly.")

0 commit comments

Comments
 (0)