Skip to content

Commit

Permalink
Add extra scroll state when chat screen is initializing
Browse files Browse the repository at this point in the history
This can prevent occasional index out of range errors
  • Loading branch information
Taewan-P committed Jun 26, 2024
1 parent 8769971 commit 06976b8
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ fun ChatScreen(
val canUseChat = (chatViewModel.enabledPlatformsInChat.toSet() - appEnabledPlatforms.toSet()).isEmpty()
val groupedMessages = remember(messages) { groupMessages(messages) }
val latestMessageIndex = groupedMessages.keys.maxOrNull() ?: 0
val chatBubbleScrollStates = rememberSaveable(saver = multiScrollStateSaver) { MutableList(latestMessageIndex + 1) { ScrollState(0) } }
val chatBubbleScrollStates = rememberSaveable(saver = multiScrollStateSaver) { MutableList(latestMessageIndex + 2) { ScrollState(0) } }

LaunchedEffect(latestMessageIndex) {
val opponentBubbles = ((latestMessageIndex + 1) / 2) + 1
Expand Down

0 comments on commit 06976b8

Please sign in to comment.