Skip to content

Commit 32a2e23

Browse files
committed
Implemented stop rendering elements which are under sync process
1 parent 0002272 commit 32a2e23

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

GoInfoGame/GoInfoGame/AppQuestManager.swift

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,26 +71,31 @@ class AppQuestManager {
7171
tags.@count != 0 AND
7272
tags['ext:gig_complete'] != 'yes'
7373
"""))
74+
let yetToSyncNodeIDs = Set(dbInstance.getChangesets(synced: false, element: .node).compactMap{ Int64($0.elementId) })
7475

7576
let waysFromStorage = dbInstance.getWays(NSPredicate(format: """
7677
tags.@count != 0 AND
7778
polyline.@count > 0 AND
7879
tags['ext:gig_complete'] != 'yes'
7980
""" ))
81+
let yetToSyncWayIDs = Set(dbInstance.getChangesets(synced: false, element: .way).compactMap{ Int64($0.elementId) })
82+
8083
debugPrint("converting to nods: start \(Date())")
81-
let nodeElements = nodesFromStorage.map({ node in
82-
autoreleasepool {
83-
node.asNode()
84+
let nodeElements: [Node] = nodesFromStorage.compactMap { node in
85+
if yetToSyncNodeIDs.contains(node.id) {
86+
return nil
8487
}
85-
})
88+
return node.asNode()
89+
}
90+
8691
debugPrint("converting to nods: end \(Date())")
8792
debugPrint("converting to way: start \(Date())")
88-
let wayElements = waysFromStorage.map({ way in
89-
autoreleasepool {
90-
way.asWay()
93+
let wayElements: [Way] = waysFromStorage.compactMap{ way in
94+
if yetToSyncWayIDs.contains(way.id) {
95+
return nil
9196
}
92-
93-
})
97+
return way.asWay()
98+
}
9499

95100
debugPrint("converting to way: end \(Date())")
96101
// Get the quests for nodes

GoInfoGame/GoInfoGame/DataBase/DatabaseConnector.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,13 @@ class DatabaseConnector {
331331
return realm.objects(StoredChangeset.self).filter(NSPredicate(format: predicateString))
332332
}
333333

334+
func getChangesets(synced: Bool, element: ElementType) -> Results<StoredChangeset> {
335+
let realm = try! Realm(configuration: RealmConfig.configuration)
336+
let syncString = synced ? "updatedVersion != -1" : "updatedVersion == -1"
337+
let predicateString = "\(syncString) AND elementType == \"\(element)\""
338+
return realm.objects(StoredChangeset.self).filter(NSPredicate(format: predicateString))
339+
}
340+
334341
func getChangeset(for id: String) -> StoredChangeset? {
335342
let realm = try! Realm(configuration: RealmConfig.configuration)
336343
return realm.object(ofType: StoredChangeset.self, forPrimaryKey: id)

0 commit comments

Comments
 (0)