From 008bbd8c3809f9f7565a13a3ebc2f78dcbeb058a Mon Sep 17 00:00:00 2001 From: andrew Date: Sun, 15 Oct 2023 01:11:00 +1030 Subject: [PATCH] Optimise DAR message expiry update & lookup --- .../securesms/notifications/MarkReadReceiver.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/notifications/MarkReadReceiver.kt b/app/src/main/java/org/thoughtcrime/securesms/notifications/MarkReadReceiver.kt index 7bf4d12615..b9a5754f40 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/notifications/MarkReadReceiver.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/notifications/MarkReadReceiver.kt @@ -69,19 +69,20 @@ class MarkReadReceiver : BroadcastReceiver() { markedReadMessages.forEach { scheduleDeletion(context, it.expirationInfo) } - getHashToMessage(context, markedReadMessages)?.let { + hashToDisappearAfterReadMessage(context, markedReadMessages)?.let { fetchUpdatedExpiriesAndScheduleDeletion(context, it) shortenExpiryOfDisappearingAfterRead(context, it) } } - private fun getHashToMessage( + private fun hashToDisappearAfterReadMessage( context: Context, markedReadMessages: List ): Map? { val loki = DatabaseComponent.get(context).lokiMessageDatabase() return markedReadMessages + .filter { it.guessExpiryType() == ExpiryType.AFTER_READ } .associateByNotNull { it.expirationInfo.run { loki.getMessageServerHash(id, isMms) } } .takeIf { it.isNotEmpty() } } @@ -90,8 +91,7 @@ class MarkReadReceiver : BroadcastReceiver() { context: Context, hashToMessage: Map ) { - hashToMessage.filterValues { it.guessExpiryType() == ExpiryType.AFTER_READ } - .entries + hashToMessage.entries .groupBy( keySelector = { it.value.expirationInfo.expiresIn }, valueTransform = { it.key }