multiplatform: mark chat non deleted only on send/receive (keep chatDeleted flag on open) (#4664)

This commit is contained in:
Diogo
2024-08-12 16:50:36 +01:00
committed by GitHub
parent 9871ebb3b1
commit d1f704d160
3 changed files with 5 additions and 9 deletions
@@ -275,6 +275,11 @@ object ChatModel {
}
}
suspend fun addChatItem(rhId: Long?, cInfo: ChatInfo, cItem: ChatItem) {
// mark chat non deleted
if (cInfo is ChatInfo.Direct && cInfo.chatDeleted) {
val updatedContact = cInfo.contact.copy(chatDeleted = false)
updateContact(rhId, updatedContact)
}
// update previews
val i = getChatIndex(rhId, cInfo.id)
val chat: Chat
@@ -2136,12 +2136,6 @@ object ChatController {
val cInfo = r.chatItem.chatInfo
val cItem = r.chatItem.chatItem
if (active(r.user)) {
if (cInfo is ChatInfo.Direct && cInfo.chatDeleted) {
val updatedContact = cInfo.contact.copy(chatDeleted = false)
withChats {
updateContact(rhId, updatedContact)
}
}
withChats {
addChatItem(rhId, cInfo, cItem)
}
@@ -61,9 +61,6 @@ fun ContactListNavLinkView(chat: Chat, nextChatSelected: State<Boolean>, showDel
ContactType.CHAT_DELETED -> {
withApi {
openChat(rhId, chat.chatInfo, chatModel)
withChats {
updateContact(rhId, chat.chatInfo.contact.copy(chatDeleted = false))
}
ModalManager.start.closeModals()
}
}