@@ -83,7 +83,6 @@ class DatasyncManager {
8383 var waysToSync : [ String : StoredChangeset ] = [ : ]
8484
8585 for cs in validChangesets {
86- let intId = Int ( cs. elementId)
8786 if cs. elementType == . node {
8887 nodesToSync [ cs. id] = cs
8988 } else if cs. elementType == . way {
@@ -104,9 +103,7 @@ class DatasyncManager {
104103 do {
105104 let status = try await syncNode ( node: payload, exclude_gig_tags: exclude_gig_tags, editedTags: node. tags. toDictionary ( ) )
106105 if status. result {
107- DispatchQueue . main. async {
108- self . dbInstance. assignChangesetId ( obj: key, changesetId: 0 , updatedVersion: status. version)
109- }
106+ _ = self . dbInstance. assignChangesetId ( obj: key, changesetId: 0 , updatedVersion: status. version)
110107 print ( " ✅ Node sync finished: \( payload. id) " )
111108 } else {
112109 print ( " ❌ Node sync failed silently: \( payload. id) " )
@@ -125,9 +122,7 @@ class DatasyncManager {
125122 do {
126123 let status = try await syncWay ( way: payload, exclude_gig_tags: exclude_gig_tags, editedTags: way. tags. toDictionary ( ) )
127124 if status. result {
128- DispatchQueue . main. async {
129- self . dbInstance. assignChangesetId ( obj: key, changesetId: 0 , updatedVersion: status. version)
130- }
125+ _ = self . dbInstance. assignChangesetId ( obj: key, changesetId: 0 , updatedVersion: status. version)
131126 print ( " ✅ Way sync finished: \( payload. id) " )
132127 } else {
133128 print ( " ❌ Way sync failed silently: \( payload. id) " )
@@ -167,15 +162,6 @@ class DatasyncManager {
167162 DatabaseConnector . shared. saveOSMElements ( [ newNode] )
168163 }
169164 }
170-
171- func syncDataDummy( ) async {
172-
173- let changesets = dbInstance. getChangesets ( )
174- print ( " Starting to sync data " )
175- for changeset in changesets {
176- let result = await dummyTask ( )
177- }
178- }
179165
180166 func dummyTask( ) async -> Result < Bool , Error > {
181167 do {
@@ -249,7 +235,6 @@ class DatasyncManager {
249235 let changesetUploadBody = " <osmChange version= \" 0.6 \" generator= \" GIG Change generator \" > " + wayBodyString + " </osmChange> "
250236 let workspaceId = KeychainManager . load ( key: " workspaceID " )
251237 let wayBody = changesetUploadBody. data ( using: . utf8)
252- let wayId = " \( localWay. id) "
253238 let newVersion = way. version + 1
254239 print ( " Uploading changeset \( changesetUploadBody) " )
255240 guard let accessToken = KeychainManager . load ( key: " accessToken " ) else {
@@ -278,9 +263,7 @@ class DatasyncManager {
278263 tags [ key] = value
279264 }
280265 }
281- DispatchQueue . main. async {
282- _ = DatabaseConnector . shared. addWayTags ( id: id, tags: tags, version: newVersion)
283- }
266+ _ = DatabaseConnector . shared. addWayTags ( id: id, tags: tags, version: newVersion)
284267 continuation. resume ( returning: newVersion)
285268
286269 case . failure( let error) :
@@ -293,7 +276,7 @@ class DatasyncManager {
293276
294277 // utility function to act as substitute for osmConnection functions
295278 func updateNode( node: OSMNode , exclude_gig_tags: Bool ) async throws -> Int {
296- var localNode = node
279+ let localNode = node
297280 let nodeBodyString = localNode. toPayload ( exclude_gig_tags: exclude_gig_tags)
298281 let changesetUploadBody = " <osmChange version= \" 0.6 \" generator= \" GIG Change generator \" > " + nodeBodyString + " </osmChange> "
299282 let workspaceId = KeychainManager . load ( key: " workspaceID " )
@@ -333,10 +316,8 @@ class DatasyncManager {
333316 }
334317 }
335318 SyncLogger . shared. logStep ( " Node Updated ---- \( updatedNode. tags) " )
336- DispatchQueue . main. async {
337319
338- _ = DatabaseConnector . shared. addNodeTags ( id: updatedNode. id, tags: updatedNode. tags, version: newVersion)
339- }
320+ _ = DatabaseConnector . shared. addNodeTags ( id: updatedNode. id, tags: updatedNode. tags, version: newVersion)
340321 continuation. resume ( returning: newVersion)
341322 case . failure( let error) :
342323 print ( error)
@@ -348,7 +329,7 @@ class DatasyncManager {
348329 }
349330
350331 func uploadNode( node: OSMNode , exclude_gig_tags: Bool = false ) async throws -> Bool {
351- var localNode = node
332+ let localNode = node
352333 let nodeBodyString = localNode. toCreatePayload ( exclude_gig_tags: exclude_gig_tags)
353334 let changesetUploadBody = " <osmChange version= \" 0.6 \" generator= \" GIG Change generator \" > " + nodeBodyString + " </osmChange> "
354335 let workspaceId = KeychainManager . load ( key: " workspaceID " )
@@ -374,7 +355,7 @@ class DatasyncManager {
374355 }
375356
376357 func updateWay2( way: OSMWay , exclude_gig_tags: Bool , editedTags: [ String : String ] ) async throws -> Int {
377- var localWay = way
358+ let localWay = way
378359 let wayId = " \( localWay. id) "
379360 var updatedResult : Int = - 1
380361 do {
@@ -402,7 +383,7 @@ class DatasyncManager {
402383 }
403384
404385 func updateNode2( node: OSMNode , exclude_gig_tags: Bool , editedTags: [ String : String ] ) async throws -> Int {
405- var localNode = node
386+ let localNode = node
406387
407388 let nodeId = " \( localNode. id) "
408389 SyncLogger . shared. logStep ( " Updating node \( nodeId) under new changeset " )
@@ -603,9 +584,7 @@ class DatasyncManager {
603584 //Step 2: Update Node
604585 let newVersion = try await updateNode2 ( node: localNode, exclude_gig_tags: exclude_gig_tags, editedTags: editedTags)
605586 localNode. version = newVersion
606- DispatchQueue . main. async {
607- self . dbInstance. updateNodeVersion ( nodeId: String ( localNode. id) , version: newVersion)
608- }
587+ _ = self . dbInstance. updateNodeVersion ( nodeId: String ( localNode. id) , version: newVersion)
609588
610589 //Stepp 3:Close changeset
611590 SyncLogger . shared. logStep ( " Close Changeset " )
@@ -653,9 +632,7 @@ class DatasyncManager {
653632
654633 localWay. version = newVersion
655634
656- DispatchQueue . main. async {
657- self . dbInstance. updateWayVersion ( wayId: String ( localWay. id) , version: newVersion)
658- }
635+ _ = self . dbInstance. updateWayVersion ( wayId: String ( localWay. id) , version: newVersion)
659636 let result = try await closeChangeset ( id: String ( changesetID) )
660637 return ( result, newVersion)
661638
0 commit comments