Skip to content

Commit f3a421a

Browse files
authored
fix(fc/messaging): only store pageIndex if prevKey not set
Prevent the chat scrolling in on open
1 parent 74637df commit f3a421a

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

services/flipchat/sdk/src/main/kotlin/xyz/flipchat/chat/paging/MessagingPagingSource.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,12 @@ internal class MessagingPagingSource(
4141
val messages =
4242
db.conversationMessageDao()
4343
.getPagedMessagesWithDetails(chatId, pageSize, offset, userId())
44-
.map { it.copy(pageIndex = currentPage) }
4544

4645
val prevKey = if (currentPage > 0 && messages.isNotEmpty()) currentPage - 1 else null
4746
val nextKey = if (messages.size < pageSize) null else currentPage + 1
4847

4948
LoadResult.Page(
50-
data = messages,
49+
data = messages.map { if (prevKey == null) it.copy(pageIndex = currentPage) else it },
5150
prevKey = prevKey,
5251
nextKey = nextKey,
5352
)
@@ -57,4 +56,3 @@ internal class MessagingPagingSource(
5756
}
5857
}
5958
}
60-

0 commit comments

Comments
 (0)