mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-12 11:14:20 +00:00
Optimise DAR message expiry update & lookup
This commit is contained in:
parent
793fe63260
commit
008bbd8c38
@ -69,19 +69,20 @@ class MarkReadReceiver : BroadcastReceiver() {
|
|||||||
|
|
||||||
markedReadMessages.forEach { scheduleDeletion(context, it.expirationInfo) }
|
markedReadMessages.forEach { scheduleDeletion(context, it.expirationInfo) }
|
||||||
|
|
||||||
getHashToMessage(context, markedReadMessages)?.let {
|
hashToDisappearAfterReadMessage(context, markedReadMessages)?.let {
|
||||||
fetchUpdatedExpiriesAndScheduleDeletion(context, it)
|
fetchUpdatedExpiriesAndScheduleDeletion(context, it)
|
||||||
shortenExpiryOfDisappearingAfterRead(context, it)
|
shortenExpiryOfDisappearingAfterRead(context, it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getHashToMessage(
|
private fun hashToDisappearAfterReadMessage(
|
||||||
context: Context,
|
context: Context,
|
||||||
markedReadMessages: List<MarkedMessageInfo>
|
markedReadMessages: List<MarkedMessageInfo>
|
||||||
): Map<String, MarkedMessageInfo>? {
|
): Map<String, MarkedMessageInfo>? {
|
||||||
val loki = DatabaseComponent.get(context).lokiMessageDatabase()
|
val loki = DatabaseComponent.get(context).lokiMessageDatabase()
|
||||||
|
|
||||||
return markedReadMessages
|
return markedReadMessages
|
||||||
|
.filter { it.guessExpiryType() == ExpiryType.AFTER_READ }
|
||||||
.associateByNotNull { it.expirationInfo.run { loki.getMessageServerHash(id, isMms) } }
|
.associateByNotNull { it.expirationInfo.run { loki.getMessageServerHash(id, isMms) } }
|
||||||
.takeIf { it.isNotEmpty() }
|
.takeIf { it.isNotEmpty() }
|
||||||
}
|
}
|
||||||
@ -90,8 +91,7 @@ class MarkReadReceiver : BroadcastReceiver() {
|
|||||||
context: Context,
|
context: Context,
|
||||||
hashToMessage: Map<String, MarkedMessageInfo>
|
hashToMessage: Map<String, MarkedMessageInfo>
|
||||||
) {
|
) {
|
||||||
hashToMessage.filterValues { it.guessExpiryType() == ExpiryType.AFTER_READ }
|
hashToMessage.entries
|
||||||
.entries
|
|
||||||
.groupBy(
|
.groupBy(
|
||||||
keySelector = { it.value.expirationInfo.expiresIn },
|
keySelector = { it.value.expirationInfo.expiresIn },
|
||||||
valueTransform = { it.key }
|
valueTransform = { it.key }
|
||||||
|
Loading…
Reference in New Issue
Block a user