Fix quick search and download label reordering

This is a regression introduced by 6277d7d.
This commit is contained in:
FooIbar authored and renovate[bot] committed 2024-06-01 22:15:44 +08:00
1 parent 07d100fcc0
commit 2cce55953f
2 files changed
+6 -5

No files matched your search

@@ -333,7 +333,8 @@ fun DownloadsScreen(navigator: DestinationsNavigator) = composing(navigator) {
)
}
itemsIndexed(groupList, key = { _, (id) -> id }) { index, (id, label) ->
itemsIndexed(groupList, key = { _, (id) -> id }) { itemIndex, (id, label) ->
val index by rememberUpdatedState(itemIndex)
val item by rememberUpdatedState(label)
// Not using rememberSwipeToDismissBoxState to prevent LazyColumn from reusing it
val dismissState = remember { SwipeToDismissBoxState(SwipeToDismissBoxValue.Settled, density, positionalThreshold = positionalThreshold) }
@@ -385,7 +385,8 @@ fun GalleryListScreen(lub: ListUrlBuilder, navigator: DestinationsNavigator) = c
stickyHeader {
HorizontalDivider()
}
itemsIndexed(quickSearchList, key = { _, item -> item.id!! }) { index, item ->
itemsIndexed(quickSearchList, key = { _, item -> item.id!! }) { itemIndex, item ->
val index by rememberUpdatedState(itemIndex)
ReorderableItem(reorderableLazyListState, key = item.id!!) { isDragging ->
// Not using rememberSwipeToDismissBoxState to prevent LazyColumn from reusing it
val dismissState = remember { SwipeToDismissBoxState(SwipeToDismissBoxValue.Settled, density, positionalThreshold = positionalThreshold) }
@@ -399,11 +400,10 @@ fun GalleryListScreen(lub: ListUrlBuilder, navigator: DestinationsNavigator) = c
}.onSuccess {
EhDB.deleteQuickSearch(item)
with(quickSearchList) {
val removeIndex = indexOf(item)
subList(removeIndex + 1, size).forEach {
subList(index + 1, size).forEach {
it.position--
}
removeAt(removeIndex)
removeAt(index)
}
}.onFailure {
dismissState.reset()