Skip to content

Commit 48bcf34

Browse files
committed
do not apply verification date filter to bundled places
1 parent 5b85ddc commit 48bcf34

2 files changed

Lines changed: 12 additions & 14 deletions

File tree

app/src/main/kotlin/org/btcmap/db/table/place/PlaceQueries.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ class PlaceQueries(private val conn: SQLiteConnection) {
110110
append("$ICON <> 'local_atm' AND $ICON <> 'currency_exchange'")
111111
append(" AND $LAT >= ?1 AND $LAT <= ?2 AND $LON >= ?3 AND $LON <= ?4")
112112
if (minVerifiedAt != null) {
113-
append(" AND $VERIFIED_AT >= ?5")
113+
append("AND ($BUNDLED = 1 OR $VERIFIED_AT >= ?5)")
114114
}
115115
}
116116
conn.prepare(

app/src/main/kotlin/org/btcmap/map/MapFragment.kt

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import android.content.pm.PackageManager
77
import android.content.res.Configuration
88
import android.location.Location
99
import android.os.Bundle
10+
import android.util.Log
1011
import android.view.LayoutInflater
1112
import android.view.View
1213
import android.view.ViewGroup
@@ -118,7 +119,6 @@ class MapFragment : Fragment() {
118119
}
119120
}
120121

121-
private var initialLoadInProgress = false
122122
private var dbCallCount = 0
123123
private var lastDbCallTimeMs = 0L
124124
private var lastMerchantsGeoJson: String? = null
@@ -237,9 +237,6 @@ class MapFragment : Fragment() {
237237

238238
binding.map.getMapAsync {
239239
it.addOnCameraIdleListener {
240-
if (initialLoadInProgress) {
241-
initialLoadInProgress = false
242-
}
243240
prefs.mapViewport = it.projection.visibleRegion.latLngBounds
244241
val center = it.projection.visibleRegion.latLngBounds.center
245242
viewLifecycleOwner.lifecycleScope.launch {
@@ -337,21 +334,28 @@ class MapFragment : Fragment() {
337334
viewLifecycleOwner.repeatOnLifecycle(Lifecycle.State.RESUMED) {
338335
binding.sync.isVisible = true
339336

337+
Log.d("map_fragment", "starting sync")
340338
val importResult = BundledPlaces.import(requireContext(), db())
341339

340+
Log.d("map_fragment", "imported ${importResult.placesImported} places from assets")
342341
if (importResult.placesImported > 0) {
343342
setFilter(filter)
344343
}
345344

346-
if (sync().syncPlaces().rowsAffected > 0) {
345+
Log.d("map_fragment", "fetching new and updated places")
346+
val syncPlacesRes = sync().syncPlaces()
347+
Log.d("map_fragment", "got ${syncPlacesRes.rowsAffected} new and updated places")
348+
if (syncPlacesRes.rowsAffected > 0) {
347349
setFilter(filter)
348350
}
349351

350-
if (sync().syncEvents().rowsAffected > 0) {
352+
if (sync().syncEvents().rowsAffected > 0 && filter == Filter.EVENTS) {
351353
setFilter(filter)
352354
}
353355

354-
if (sync().syncComments().rowsAffected > 0) {
356+
val syncCommentsRes = sync().syncComments()
357+
Log.d("map_fragment", "got ${syncCommentsRes.rowsAffected} new and updated comments")
358+
if (syncCommentsRes.rowsAffected > 0 && (filter == Filter.MERCHANTS || filter == Filter.EXCHANGES)) {
355359
setFilter(filter)
356360
}
357361

@@ -363,8 +367,6 @@ class MapFragment : Fragment() {
363367
viewLifecycleOwner, backPressedCallback
364368
)
365369

366-
initialLoadInProgress = true
367-
368370
viewLifecycleOwner.lifecycleScope.launch {
369371
viewLifecycleOwner.repeatOnLifecycle(Lifecycle.State.CREATED) {
370372
binding.map.getMapAsync {
@@ -716,10 +718,6 @@ class MapFragment : Fragment() {
716718
dbCallCount = 0
717719
lastDbCallTimeMs = 0L
718720

719-
if (initialLoadInProgress) {
720-
return
721-
}
722-
723721
when (filter) {
724722
Filter.MERCHANTS -> showMerchants()
725723
Filter.EVENTS -> showEvents()

0 commit comments

Comments
 (0)