[优化] 修复搜索时的闪退问题
This commit is contained in:
1 file changed
+5
-1
@@ -16,6 +16,7 @@ import androidx.compose.foundation.layout.width
|
|||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
import androidx.compose.foundation.lazy.LazyRow
|
import androidx.compose.foundation.lazy.LazyRow
|
||||||
import androidx.compose.foundation.lazy.items
|
import androidx.compose.foundation.lazy.items
|
||||||
|
import androidx.compose.foundation.lazy.itemsIndexed
|
||||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||||
@@ -334,7 +335,10 @@ fun SearchScreen(
|
|||||||
),
|
),
|
||||||
verticalArrangement = Arrangement.spacedBy(6.dp)
|
verticalArrangement = Arrangement.spacedBy(6.dp)
|
||||||
) {
|
) {
|
||||||
items(items = state.results, key = { it.bookUrl }) { book ->
|
itemsIndexed(
|
||||||
|
items = state.results,
|
||||||
|
key = { index, book -> "${book.origin}:${book.bookUrl}:$index" }
|
||||||
|
) { _, book ->
|
||||||
val shelfStateFlow = remember(book.bookUrl) {
|
val shelfStateFlow = remember(book.bookUrl) {
|
||||||
viewModel.getBookShelfStateFlow(book)
|
viewModel.getBookShelfStateFlow(book)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user