diff --git a/CHANGELOG.md b/CHANGELOG.md index a31fa4936b1..dc1baf3979a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 0.12.7 + +* `Repos`: + * `Cache`: + * Force `WriteCRUDCacheRepo` to subscribe on new and updated objects of parent repo +* `Pagination`: + * New function `changeResultsUnchecked(Pagination)` + ## 0.12.6 * `MimeeTypes>`: diff --git a/gradle.properties b/gradle.properties index 01053334011..22ec9736793 100644 --- a/gradle.properties +++ b/gradle.properties @@ -14,5 +14,5 @@ crypto_js_version=4.1.1 # Project data group=dev.inmo -version=0.12.6 -android_code_version=145 +version=0.12.7 +android_code_version=146 diff --git a/pagination/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/PaginationResult.kt b/pagination/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/PaginationResult.kt index 6a62cf5bdfa..3abd96bc9b5 100644 --- a/pagination/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/PaginationResult.kt +++ b/pagination/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/PaginationResult.kt @@ -48,6 +48,14 @@ data class PaginationResult( } fun emptyPaginationResult() = PaginationResult(0, 0, emptyList(), 0L) +fun emptyPaginationResult( + basePagination: Pagination +) = PaginationResult( + basePagination.page, + basePagination.size, + emptyList(), + 0L +) /** * @return New [PaginationResult] with [data] without checking of data sizes equality diff --git a/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/CRUDCacheRepo.kt b/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/CRUDCacheRepo.kt index 28ab069b0ff..413e116cd92 100644 --- a/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/CRUDCacheRepo.kt +++ b/repos/cache/src/commonMain/kotlin/dev/inmo/micro_utils/repos/cache/CRUDCacheRepo.kt @@ -33,6 +33,14 @@ open class WriteCRUDCacheRepo( override val updatedObjectsFlow: Flow by parentRepo::updatedObjectsFlow override val deletedObjectsIdsFlow: Flow by parentRepo::deletedObjectsIdsFlow + val createdObjectsFlowJob = parentRepo.newObjectsFlow.onEach { + kvCache.set(idGetter(it), it) + }.launchIn(scope) + + val updatedObjectsFlowJob = parentRepo.updatedObjectsFlow.onEach { + kvCache.set(idGetter(it), it) + }.launchIn(scope) + val deletedObjectsFlowJob = parentRepo.deletedObjectsIdsFlow.onEach { kvCache.unset(it) }.launchIn(scope)