Compare commits

...

2 Commits

Author SHA1 Message Date
Avently d1b48e583e don't throttle own messages on desktop 2024-08-10 12:44:36 +09:00
Avently 2e78e8acf5 android, desktop: fix to chat throttler 2024-08-10 12:27:37 +09:00
@@ -206,7 +206,10 @@ object ChatModel {
class ChatsContext {
val chats = _chats
fun addChat(chat: Chat) = chats.add(index = 0, chat)
fun addChat(chat: Chat) {
chat.popTs = Clock.System.now()
chats.add(index = 0, chat)
}
fun updateChatInfo(rhId: Long?, cInfo: ChatInfo) {
val i = getChatIndex(rhId, cInfo.id)
@@ -252,8 +255,7 @@ object ChatModel {
}
fun updateChats(newChats: List<Chat>) {
chats.clear()
chats.addAll(newChats)
chats.replaceAll(newChats)
val cId = chatId.value
// If chat is null, it was deleted in background after apiGetChats call
@@ -268,7 +270,7 @@ object ChatModel {
chats[i] = chat
} else {
// invalid state, correcting
chats.add(index = 0, chat)
addChat(chat)
}
}
suspend fun addChatItem(rhId: Long?, cInfo: ChatInfo, cItem: ChatItem) {
@@ -303,7 +305,12 @@ object ChatModel {
else
chat.chatStats
)
popChatCollector.addChat(chat.remoteHostId, chat.id)
if (appPlatform.isDesktop && cItem.chatDir.sent) {
chat.popTs = Clock.System.now()
chats.add(0, chats.removeAt(i))
} else {
popChatCollector.addChat(chat.remoteHostId, chat.id)
}
} else {
addChat(Chat(remoteHostId = rhId, chatInfo = cInfo, chatItems = arrayListOf(cItem)))
}