mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-09 22:04:24 +01:00
handle CLEARED_CHAT for scrolling into past
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
85f4d8cd92
commit
299e8508c4
@ -481,8 +481,15 @@ class OfflineFirstChatRepository @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
ChatMessage.SystemMessageType.CLEARED_CHAT -> {
|
ChatMessage.SystemMessageType.CLEARED_CHAT -> {
|
||||||
val pattern = "$internalConversationId%" // LIKE "<accountId>@<conversationId>@%"
|
// for lookIntoFuture just deleting everything would be fine.
|
||||||
chatDao.clearAllMessagesForUser(pattern)
|
// But lets say we did not open the chat for a while and in between it was cleared.
|
||||||
|
// We just load the last 100 messages but this don't contain the system message.
|
||||||
|
// We scroll up and load the system message. Deleting everything is not an option as we
|
||||||
|
// would loose the messages that we want to keep. We only want to
|
||||||
|
// delete the messages and chatBlocks older than the system message.
|
||||||
|
|
||||||
|
chatDao.deleteMessagesOlderThan(internalConversationId, messageJson.id)
|
||||||
|
chatBlocksDao.deleteChatBlocksOlderThan(internalConversationId, messageJson.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {}
|
else -> {}
|
||||||
|
@ -89,4 +89,13 @@ interface ChatBlocksDao {
|
|||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
fun clearChatBlocksForUser(pattern: String)
|
fun clearChatBlocksForUser(pattern: String)
|
||||||
|
|
||||||
|
@Query(
|
||||||
|
"""
|
||||||
|
DELETE FROM ChatBlocks
|
||||||
|
WHERE internalConversationId = :internalConversationId
|
||||||
|
AND oldestMessageId < :messageId
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
fun deleteChatBlocksOlderThan(internalConversationId: String, messageId: Long)
|
||||||
}
|
}
|
||||||
|
@ -131,4 +131,13 @@ interface ChatMessagesDao {
|
|||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
fun clearAllMessagesForUser(pattern: String)
|
fun clearAllMessagesForUser(pattern: String)
|
||||||
|
|
||||||
|
@Query(
|
||||||
|
"""
|
||||||
|
DELETE FROM chatmessages
|
||||||
|
WHERE internalConversationId = :internalConversationId
|
||||||
|
AND id < :messageId
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
fun deleteMessagesOlderThan(internalConversationId: String, messageId: Long)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user