Skip to content

Commit 05d738b

Browse files
authored
Merge pull request #92 from TaskarCenterAtUW/feature-feedback-minor-changes
Feature feedback minor changes
2 parents a6238f9 + e8e559c commit 05d738b

File tree

9 files changed

+31
-17
lines changed

9 files changed

+31
-17
lines changed

GoInfoGame/GoInfoGame/AppQuestManager.swift

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,24 @@ class AppQuestManager {
6363

6464

6565

66+
6667
// Fetches all the available quests from Database
6768
func fetchQuestsFromDB() -> [DisplayUnitWithCoordinate] {
68-
let nodesFromStorage = dbInstance.getNodes()
69-
let waysFromStorage = dbInstance.getWays()
69+
70+
let nodesFromStorage = dbInstance.getNodes().filter { n in
71+
n.tags.count != 0
72+
}
73+
let waysFromStorage = dbInstance.getWays().filter{w in w.tags.count != 0 }
7074
let nodeElements = nodesFromStorage.map({$0.asNode()})
7175
let wayElements = waysFromStorage.map({$0.asWay()})
72-
76+
7377
// Get the quests for nodes
7478
var nodeQuests: [any Quest] = []
7579
var wayQuests: [any Quest] = []
7680
let allQuests = QuestsRepository.shared.applicableQuests
7781
var displayUnits : [DisplayUnitWithCoordinate] = []
7882

83+
7984
// Get the quests for ways
8085
for node in nodeElements {
8186
// Get the quests and try to iterate

GoInfoGame/GoInfoGame/data/DatasyncManager.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ class DatasyncManager {
3939
else {
4040
isSynching = true
4141
}
42+
// check if the user is logged in
43+
// if user not logged in, isSynching-false and return
44+
guard let accessToken = osmConnection.accessToken else {
45+
isSynching = false
46+
return
47+
}
4248
let changesets = dbInstance.getChangesets()
4349
print("Starting to sync data")
4450
var nodesToSync: [String:StoredNode] = [:]
@@ -178,6 +184,7 @@ class DatasyncManager {
178184
}
179185
}
180186

187+
@MainActor
181188
func syncWay(way: inout OSMWay) async -> Result<Bool,Error> {
182189
do {
183190
// open changeset

GoInfoGame/GoInfoGame/quests/CrossingMarking/CrossMarking.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ import Foundation
99
import UIKit
1010
import SwiftUI
1111
import osmparser
12-
12+
// This is to figure out what type of marking is there for the crossing
1313
class CrossMarking: QuestBase, Quest {
1414
typealias AnswerClass = CrossingAnswer
1515
var _internalExpression: ElementFilterExpression?
1616
var title: String = "Cross Marking"
17-
var filter: String = "ways with highway=footway and !footway"
17+
var filter: String = "ways with highway=footway and footway=crossing and !crossing"
1818
var icon: UIImage = #imageLiteral(resourceName: "pedestrian")
1919
var wikiLink: String = ""
2020
var changesetComment: String = ""

GoInfoGame/GoInfoGame/quests/QuestProtocols.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,14 @@ class QuestBase {
4646
print("Unknown Stored element type received")
4747
}
4848
// Sync using datasyncmanager
49+
50+
// Dismiss sheet after syncing to db
51+
MapViewPublisher.shared.dismissSheet.send(true)
52+
4953

5054
DatasyncManager.shared.syncDataToOSM {
5155
print("SYNC DONE")
52-
DispatchQueue.main.async {
53-
MapViewPublisher.shared.dismissSheet.send(true)
54-
}
56+
5557
}
5658
}
5759
}

GoInfoGame/GoInfoGame/quests/QuestsRepository.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class QuestsRepository {
1212
static let shared = QuestsRepository()
1313
private init() {}
1414

15-
var applicableQuests: [ any Quest] = [
15+
let applicableQuests: [ any Quest] = [
1616

1717
CrossingType(),
1818
CrossingIsland(),

GoInfoGame/GoInfoGame/quests/TactilePavingCrosswalk/TactilePavingCrosswalk.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class TactilePavingCrosswalk :QuestBase, Quest {
3030
return _internalExpression
3131
}
3232
else {
33-
print("<>")
33+
// print("<>")
3434
_internalExpression = try? filter.toElementFilterExpression()
3535
return _internalExpression
3636
}

GoInfoGame/GoInfoGame/quests/TactilePavingSteps/TactilePavingSteps.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class TactilePavingSteps :QuestBase, Quest {
3030
return _internalExpression
3131
}
3232
else {
33-
print("<>")
33+
// print("<>")
3434
_internalExpression = try? filter.toElementFilterExpression()
3535
return _internalExpression
3636
}

GoInfoGame/GoInfoGame/quests/WayLit/WayLit.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class WayLit: QuestBase, Quest {
6161
return _internalExpression
6262
}
6363
else {
64-
print("<>")
64+
// print("<>")
6565
_internalExpression = try? filter.toElementFilterExpression()
6666
return _internalExpression
6767
}

GoInfoGame/osmapi/OSMConnection.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public class OSMConnection {
7070
print("Invalid URL given")
7171
return
7272
}
73-
BaseNetworkManager.shared.addOrSetHeaders(header: "Authorization", value: "Basic \(self.userCreds.getHeaderData())")
73+
BaseNetworkManager.shared.addOrSetHeaders(header: "Authorization", value: "Bearer \(self.accessToken!)")
7474
BaseNetworkManager.shared.postData(url: url,method: "PUT" ,body: OSMChangesetPayload()) { (result: Result<Int,Error>) in
7575
switch result {
7676
case .success(let changesetID):
@@ -93,7 +93,7 @@ public class OSMConnection {
9393
print("Invalid URL given")
9494
return
9595
}
96-
BaseNetworkManager.shared.addOrSetHeaders(header: "Authorization", value: "Basic \(self.userCreds.getHeaderData())")
96+
BaseNetworkManager.shared.addOrSetHeaders(header: "Authorization", value: "Bearer \(self.accessToken!)")
9797
BaseNetworkManager.shared.postData(url: url,method: "PUT" ,body: ["tag":"xyz"],expectEmpty: true) { (result: Result<Bool,Error>) in
9898
switch result {
9999
case .success(let closedResult):
@@ -112,7 +112,7 @@ public class OSMConnection {
112112
func getChangesets(_ completion: @escaping(()->())) {
113113
let urlString = self.baseUrl.appending("changesets.json")
114114
var request = URLRequest(url: URL(string: urlString)!,timeoutInterval: Double.infinity)
115-
request.addValue("Basic \(self.userCreds.getHeaderData())", forHTTPHeaderField: "Authorization")
115+
request.addValue("Bearer \(self.accessToken!)", forHTTPHeaderField: "Authorization")
116116
request.httpMethod = "GET"
117117
let task = URLSession.shared.dataTask(with: request) { data, response, error in
118118
guard let data = data else {
@@ -148,7 +148,7 @@ public class OSMConnection {
148148
print("Invalid URL given")
149149
return
150150
}
151-
BaseNetworkManager.shared.addOrSetHeaders(header: "Authorization", value: "Basic \(self.userCreds.getHeaderData())")
151+
BaseNetworkManager.shared.addOrSetHeaders(header: "Authorization", value: "Bearer \(self.accessToken!)")
152152
// Add nodes to the same
153153
if(node.tags == nil){
154154
node.tags = [:]
@@ -172,7 +172,7 @@ public class OSMConnection {
172172
print("Invalid URL given")
173173
return
174174
}
175-
BaseNetworkManager.shared.addOrSetHeaders(header: "Authorization", value: "Basic \(self.userCreds.getHeaderData())")
175+
BaseNetworkManager.shared.addOrSetHeaders(header: "Authorization", value: "Bearer \(self.accessToken!)")
176176
// Add nodes to the same
177177

178178
tags.forEach { (key: String, value: String) in

0 commit comments

Comments
 (0)