@@ -73,6 +73,7 @@ import androidx.compose.ui.res.painterResource
73
73
import androidx.compose.ui.res.stringResource
74
74
import androidx.compose.ui.text.style.TextOverflow
75
75
import androidx.hilt.navigation.compose.hiltViewModel
76
+ import androidx.paging.LoadState
76
77
import androidx.paging.PagingData
77
78
import androidx.paging.compose.LazyPagingItems
78
79
import androidx.paging.compose.collectAsLazyPagingItems
@@ -1333,7 +1334,18 @@ fun MessageList(
1333
1334
.fillMaxWidth()
1334
1335
.padding(dimensions().spacing16x),
1335
1336
) {
1336
- val (text, prefixIconResId)= when (lazyPagingMessages.loadState.prepend.endOfPaginationReached) {
1337
+ var allMessagesPrepended by remember { mutableStateOf(false ) }
1338
+ LaunchedEffect (lazyPagingMessages.loadState) {
1339
+ // When the list is being refreshed, the load state for prepend is cleared so the app doesn't know if
1340
+ // the end of pagination is reached or not for prepend until the refresh is done, so we don't want to
1341
+ // update the allMessagesPrepended state while refreshing and in that case keep the last updated state,
1342
+ // otherwise the indicator will flicker while refreshing.
1343
+ if (lazyPagingMessages.loadState.refreshis LoadState .NotLoading ) {
1344
+ allMessagesPrepended= lazyPagingMessages.loadState.prepend.endOfPaginationReached
1345
+ }
1346
+ }
1347
+
1348
+ val (text, prefixIconResId)= when (allMessagesPrepended) {
1337
1349
true -> stringResource(R .string.conversation_history_loaded) tonull
1338
1350
false -> stringResource(R .string.conversation_history_loading) toR .drawable.ic_undo
1339
1351
}