From 147898d288b55d6cbc4b8349583f579cb2c884ab Mon Sep 17 00:00:00 2001 From: Jesse Wilson Date: Wed, 4 Oct 2023 09:28:46 -0400 Subject: [PATCH] Address PR feedback --- .../kotlin/app/cash/redwood/lazylayout/compose/LazyList.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/redwood-lazylayout-compose/src/commonMain/kotlin/app/cash/redwood/lazylayout/compose/LazyList.kt b/redwood-lazylayout-compose/src/commonMain/kotlin/app/cash/redwood/lazylayout/compose/LazyList.kt index dc0ade723e..c02d13480d 100644 --- a/redwood-lazylayout-compose/src/commonMain/kotlin/app/cash/redwood/lazylayout/compose/LazyList.kt +++ b/redwood-lazylayout-compose/src/commonMain/kotlin/app/cash/redwood/lazylayout/compose/LazyList.kt @@ -49,6 +49,8 @@ internal fun LazyList( val itemsBefore = remember(state.firstVisibleItemIndex) { (state.firstVisibleItemIndex - OffscreenItemsBufferCount / 2).coerceAtLeast(0) } val itemsAfter = remember(lastVisibleItemIndex, itemProvider.itemCount) { (itemProvider.itemCount - (lastVisibleItemIndex + OffscreenItemsBufferCount / 2).coerceAtMost(itemProvider.itemCount)).coerceAtLeast(0) } val scrollItemIndex = remember(state.scrollToItemTriggeredId) { ScrollItemIndex(state.scrollToItemTriggeredId, state.firstVisibleItemIndex) } + // TODO(jwilson): drop this down to 20 once this is fixed: + // https://github.com/cashapp/redwood/issues/1551 var placeholderPoolSize by remember { mutableStateOf(30) } LazyList( isVertical, @@ -56,7 +58,7 @@ internal fun LazyList( itemsAfter = itemsAfter, onViewportChanged = { localFirstVisibleItemIndex, localLastVisibleItemIndex -> val visibleItemCount = localLastVisibleItemIndex - localFirstVisibleItemIndex - val proposedPlaceholderPoolSize = visibleItemCount * 2 + val proposedPlaceholderPoolSize = visibleItemCount + visibleItemCount / 2 // We only ever want to increase the pool size. if (placeholderPoolSize < proposedPlaceholderPoolSize) { placeholderPoolSize = proposedPlaceholderPoolSize