mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-11-11 13:57:42 +00:00
ui: drop the page-merge application of kept updates
This commit is contained in:
1 parent
21ea35030b
commit
5dda3cc2cd
5 files changed
+23
-30
No files matched your search
@@ -737,13 +737,6 @@ object ChatModel {
|
||||
return itemAdded
|
||||
}
|
||||
|
||||
fun withDroppedUpdates(rhId: Long?, chatId: String, items: List<ChatItem>): List<ChatItem> =
|
||||
if (droppedUpdates.isEmpty() || droppedUpdatesChat != (rhId to chatId)) {
|
||||
items
|
||||
} else {
|
||||
items.map { item -> droppedUpdates.remove(item.id)?.takeIf { it.meta.updatedAt > item.meta.updatedAt } ?: item }
|
||||
}
|
||||
|
||||
fun clearDroppedUpdates() {
|
||||
droppedUpdatesChat = null
|
||||
droppedUpdates.clear()
|
||||
|
||||
+5
-5
@@ -77,7 +77,7 @@ suspend fun processLoadedChat(
|
||||
}
|
||||
}
|
||||
withContext(Dispatchers.Main) {
|
||||
chatsCtx.chatItems.replaceAll(chatsCtx.withDroppedUpdates(chat.remoteHostId, chat.id, chat.chatItems))
|
||||
chatsCtx.chatItems.replaceAll(chat.chatItems)
|
||||
chatModel.chatId.value = chat.id
|
||||
splits.value = newSplits
|
||||
if (chat.chatItems.isNotEmpty()) {
|
||||
@@ -103,7 +103,7 @@ suspend fun processLoadedChat(
|
||||
newItems.addAll(insertAt, chat.chatItems)
|
||||
withContext(Dispatchers.Main) {
|
||||
if (chatWasSwitched(chat, pagination, openAroundItemId)) return@withContext
|
||||
chatsCtx.chatItems.replaceAll(chatsCtx.withDroppedUpdates(chat.remoteHostId, chat.id, newItems))
|
||||
chatsCtx.chatItems.replaceAll(newItems)
|
||||
splits.value = newSplits
|
||||
chatState.moveUnreadAfterItem(oldUnreadSplitIndex, newUnreadSplitIndex, oldItems)
|
||||
}
|
||||
@@ -123,7 +123,7 @@ suspend fun processLoadedChat(
|
||||
newItems.addAll(indexToAdd, chat.chatItems)
|
||||
withContext(Dispatchers.Main) {
|
||||
if (chatWasSwitched(chat, pagination, openAroundItemId)) return@withContext
|
||||
chatsCtx.chatItems.replaceAll(chatsCtx.withDroppedUpdates(chat.remoteHostId, chat.id, newItems))
|
||||
chatsCtx.chatItems.replaceAll(newItems)
|
||||
splits.value = newSplits
|
||||
chatState.moveUnreadAfterItem(splits.value.firstOrNull() ?: newItems.last().id, newItems)
|
||||
// loading clear bottom area, updating number of unread items after the newest loaded item
|
||||
@@ -146,7 +146,7 @@ suspend fun processLoadedChat(
|
||||
|
||||
withContext(Dispatchers.Main) {
|
||||
if (chatWasSwitched(chat, pagination, openAroundItemId)) return@withContext
|
||||
chatsCtx.chatItems.replaceAll(chatsCtx.withDroppedUpdates(chat.remoteHostId, chat.id, newItems))
|
||||
chatsCtx.chatItems.replaceAll(newItems)
|
||||
splits.value = newSplits
|
||||
unreadAfterItemId.value = chat.chatItems.last().id
|
||||
totalAfter.value = navInfo.afterTotal
|
||||
@@ -170,7 +170,7 @@ suspend fun processLoadedChat(
|
||||
newItems.addAll(chat.chatItems)
|
||||
withContext(Dispatchers.Main) {
|
||||
if (chatWasSwitched(chat, pagination, openAroundItemId)) return@withContext
|
||||
chatsCtx.chatItems.replaceAll(chatsCtx.withDroppedUpdates(chat.remoteHostId, chat.id, newItems))
|
||||
chatsCtx.chatItems.replaceAll(newItems)
|
||||
chatState.splits.value = newSplits
|
||||
unreadAfterNewestLoaded.value = 0
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user