Skip to content

Commit

Permalink
[Quest/Malawi Core] Android App : Sync Inactive recently changed Reso…
Browse files Browse the repository at this point in the history
…urces which are being filtered (#74)

* [Quest/Malawi Core] Android App : Sync Inactive recently changed Resources which are being filtered

* Bug fix, negate evaluation

* removes resources which aren't active

* Update SyncListenerManager.kt

---------

Co-authored-by: Mabuchi Nyirenda <[email protected]>
Co-authored-by: Christopher Seven Phiri <[email protected]>
  • Loading branch information
3 people authored Jul 5, 2024
1 parent b81976d commit 5a96be2
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ constructor(

private val syncConfig by lazy { configurationRegistry.getSyncConfigs() }

private fun isInitialSync() =
sharedPreferencesHelper.read(SharedPreferenceKey.LAST_SYNC_TIMESTAMP.name, null).isNullOrBlank()

private val _onSyncListeners = mutableListOf<WeakReference<OnSyncListener>>()
val onSyncListeners: List<OnSyncListener>
get() = _onSyncListeners.mapNotNull { it.get() }
Expand Down Expand Up @@ -132,11 +135,14 @@ constructor(
}
}

filterBasedOnPerResourceType().forEach { (type, filters) ->
resourceTypeParamsMap.merge(type, filters) { list1, list2 ->
return@merge list1.toMutableList().apply { addAll(list2) }
if (isInitialSync()) {
filterBasedOnPerResourceType().forEach { (type, filters) ->
resourceTypeParamsMap.merge(type, filters) { list1, list2 ->
return@merge list1.toMutableList().apply { addAll(list2) }
}
}
}

val filterByLocationParams =
sharedPreferencesHelper.filterByResourceLocation(resourceTypeParamsMap)

Expand Down

0 comments on commit 5a96be2

Please sign in to comment.