1
0
Fork 0
mirror of https://github.com/anyproto/anytype-kotlin.git synced 2025-06-08 05:47:05 +09:00

DROID-2897 All Content | Search, subscription fixes (#1627)

This commit is contained in:
Konstantin Ivanov 2024-10-03 23:25:13 +02:00 committed by GitHub
parent f71f86a054
commit de63e10b02
Signed by: github
GPG key ID: B5690EEEBB952194
3 changed files with 21 additions and 7 deletions

View file

@ -112,7 +112,6 @@ class AllContentViewModel(
init {
Timber.d("AllContentViewModel init, spaceId:[${vmParams.spaceId.id}]")
setupInitialStateParams()
setupUiStateFlow()
setupSearchStateFlow()
setupMenuFlow()
}
@ -152,8 +151,13 @@ class AllContentViewModel(
searchObjects(searchParams).process(
success = { searchResults ->
Timber.d("Search objects by query:[$query], size: : ${searchResults.size}")
searchResultIds.value = searchResults.map { it.id }
restartSubscription.value++
if (searchResults.isEmpty()) {
uiItemsState.value = emptyList()
uiContentState.value = UiContentState.Empty
} else {
searchResultIds.value = searchResults.map { it.id }
restartSubscription.value++
}
},
failure = {
Timber.e(it, "Error searching objects by query")
@ -169,7 +173,7 @@ class AllContentViewModel(
viewModelScope.launch {
restartSubscription.flatMapLatest {
loadData()
}.collect { items ->
}.collectLatest { items ->
uiItemsState.value = items
}
}
@ -506,6 +510,11 @@ class AllContentViewModel(
}
}
fun onStart() {
Timber.d("onStart")
setupUiStateFlow()
}
fun onStop() {
Timber.d("onStop")
viewModelScope.launch {

View file

@ -3,7 +3,6 @@ package com.anytypeio.anytype.feature_allcontent.ui
import android.os.Build
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxScope
import androidx.compose.foundation.layout.Column
@ -53,6 +52,7 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.anytypeio.anytype.core_ui.common.DefaultPreviews
import com.anytypeio.anytype.core_ui.foundation.Divider
import com.anytypeio.anytype.core_ui.foundation.noRippleClickable
import com.anytypeio.anytype.core_ui.views.ButtonSize
import com.anytypeio.anytype.core_ui.views.Caption1Regular
import com.anytypeio.anytype.core_ui.views.PreviewTitle1Medium
@ -292,7 +292,7 @@ private fun ContentItems(
.padding(horizontal = 16.dp)
.bottomBorder()
.animateItem()
.clickable {
.noRippleClickable {
onItemClicked(item)
},
item = item
@ -305,7 +305,7 @@ private fun ContentItems(
.padding(horizontal = 16.dp)
.bottomBorder()
.animateItem()
.clickable {
.noRippleClickable {
onTypeClicked(item)
},
item = item