From b10fce3fc2bf3ee8dcb3bbee1cf6dc467726394c Mon Sep 17 00:00:00 2001 From: Morten Andersen Date: Fri, 6 Dec 2024 18:58:37 +0100 Subject: [PATCH] fix: Occasionally the client crashes when scrolling of the log fails in the GUI - this catches this ignorable exception fixes [OCPP-EMULATOR-BY](https://monta-app.sentry.io/issues/5959585539/) --- .../chargepoint/view/components/ChargePointLogView.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/v16/src/jvmMain/kotlin/com/monta/ocpp/emulator/chargepoint/view/components/ChargePointLogView.kt b/v16/src/jvmMain/kotlin/com/monta/ocpp/emulator/chargepoint/view/components/ChargePointLogView.kt index a716395..7f677f8 100644 --- a/v16/src/jvmMain/kotlin/com/monta/ocpp/emulator/chargepoint/view/components/ChargePointLogView.kt +++ b/v16/src/jvmMain/kotlin/com/monta/ocpp/emulator/chargepoint/view/components/ChargePointLogView.kt @@ -24,6 +24,7 @@ import com.monta.ocpp.emulator.theme.AppThemeViewModel import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import kotlinx.coroutines.withContext +import java.lang.IndexOutOfBoundsException @Composable fun chargePointLogComponent( @@ -61,7 +62,9 @@ fun chargePointLogComponent( logItems.size != 0 && navigationViewModel.windowHasFocus ) { - lazyListState.scrollToItem(logItems.size - 1) + try { + lazyListState.scrollToItem(logItems.size - 1) + } catch (ignore: IndexOutOfBoundsException) { /* ignore - this happens sometimes */ } } } }