Skip to content

Commit e08d6bb

Browse files
committed
fix search paging
1 parent 34fa0c0 commit e08d6bb

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

feature/search/src/main/java/st/slex/csplashscreen/feature/search/ui/SearchPhotosScreen.kt

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ import androidx.compose.runtime.collectAsState
77
import androidx.compose.runtime.getValue
88
import androidx.compose.runtime.remember
99
import androidx.compose.ui.Modifier
10+
import androidx.paging.LoadState
1011
import androidx.paging.compose.LazyPagingItems
12+
import kotlinx.coroutines.flow.StateFlow
1113
import st.slex.csplashscreen.core.photos.ui.component.LazyListPhotos
1214
import st.slex.csplashscreen.core.photos.ui.model.PhotoModel
1315
import st.slex.csplashscreen.feature.search.ui.components.TopAppBarSearch
1416
import st.slex.csplashscreen.feature.search.ui.components.history.LazyListHistorySearch
1517
import st.slex.csplashscreen.feature.search.ui.model.SearchItem
16-
import st.slex.csplashscreen.feature.search.ui.utils.UiExt.isNotLoading
17-
import kotlinx.coroutines.flow.StateFlow
1818

1919
@Composable
2020
fun SearchPhotosScreen(
@@ -39,22 +39,23 @@ fun SearchPhotosScreen(
3939
search = onQuery
4040
)
4141

42-
if (photos.loadState.isNotLoading) {
43-
if (photos.itemCount == 0) {
44-
LazyListHistorySearch(
45-
modifier = Modifier.weight(1f),
46-
items = searchHistory,
47-
onSearchClick = remember { onQuery },
48-
clearHistory = clearHistory
49-
)
50-
} else {
51-
LazyListPhotos(
52-
modifier = Modifier.weight(1f),
53-
items = photos,
54-
onUserClick = onUserClick,
55-
onImageClick = onImageClick,
56-
)
57-
}
42+
if (
43+
photos.loadState.refresh is LoadState.NotLoading &&
44+
photos.itemCount == 0
45+
) {
46+
LazyListHistorySearch(
47+
modifier = Modifier.weight(1f),
48+
items = searchHistory,
49+
onSearchClick = remember { onQuery },
50+
clearHistory = clearHistory
51+
)
52+
} else {
53+
LazyListPhotos(
54+
modifier = Modifier.weight(1f),
55+
items = photos,
56+
onUserClick = onUserClick,
57+
onImageClick = onImageClick,
58+
)
5859
}
5960
}
6061
}

0 commit comments

Comments
 (0)