mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-28 09:38:14 +03:00
Fix unintended deletion of conversations (+related messages&chatBlocks)
Mistake was, that the conversations from DB and sync could differ due to values. E.g. when a user changed the status, the conversations from DB and sync would differ. So there were conversations (+related messages&chatBlocks) deleted sometimes. This caused bugs that when entering a chat, all data was loaded again. In the previous implementation (before this PR), this error was only visible in the UI when you were offline (in this case, nothing was displayed!). To fix the bug, only the internalId's are compared. Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
3d37cc0831
commit
adf18020c1
1 changed files with 4 additions and 2 deletions
|
@ -131,10 +131,12 @@ class OfflineFirstConversationsRepository @Inject constructor(
|
|||
}
|
||||
|
||||
private suspend fun deleteLeftConversations(conversationsFromSync: List<ConversationEntity>) {
|
||||
val conversationsFromSyncIds = conversationsFromSync.map { it.internalId }.toSet()
|
||||
val oldConversationsFromDb = dao.getConversationsForUser(user.id!!).first()
|
||||
|
||||
val conversationsToDelete = oldConversationsFromDb.filterNot { conversationsFromSync.contains(it) }
|
||||
val conversationIdsToDelete = conversationsToDelete.map { it.internalId }
|
||||
val conversationIdsToDelete = oldConversationsFromDb
|
||||
.map { it.internalId }
|
||||
.filterNot { it in conversationsFromSyncIds }
|
||||
|
||||
dao.deleteConversations(conversationIdsToDelete)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue