From e654f1dee37f2b94748b8e960cedca5c1250dc5f Mon Sep 17 00:00:00 2001 From: Nik Clayton Date: Tue, 26 Nov 2024 20:19:03 +0100 Subject: [PATCH] fix: Prevent crash if getItem throws IndexOutOfBoundsException --- .../app/pachli/components/timeline/TimelinePagingAdapter.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/app/pachli/components/timeline/TimelinePagingAdapter.kt b/app/src/main/java/app/pachli/components/timeline/TimelinePagingAdapter.kt index 36d858d59..5a2f2517c 100644 --- a/app/src/main/java/app/pachli/components/timeline/TimelinePagingAdapter.kt +++ b/app/src/main/java/app/pachli/components/timeline/TimelinePagingAdapter.kt @@ -67,7 +67,11 @@ class TimelinePagingAdapter( position: Int, payloads: List<*>?, ) { - getItem(position)?.let { + try { + getItem(position) + } catch (e: IndexOutOfBoundsException) { + null + }?.let { (viewHolder as StatusViewHolder).setupWithStatus( pachliAccountId, it,