Cleanup MarkReadReceiver

This commit is contained in:
Andrew 2024-02-18 02:27:47 +10:30
parent 66dcae04f6
commit 2e50dc08bb

View File

@ -35,10 +35,9 @@ class MarkReadReceiver : BroadcastReceiver() {
object : AsyncTask<Void?, Void?, Void?>() { object : AsyncTask<Void?, Void?, Void?>() {
override fun doInBackground(vararg params: Void?): Void? { override fun doInBackground(vararg params: Void?): Void? {
val currentTime = nowWithOffset val currentTime = nowWithOffset
for (threadId in threadIds) { threadIds.forEach {
Log.i(TAG, "Marking as read: $threadId") Log.i(TAG, "Marking as read: $it")
val storage = shared.storage shared.storage.markConversationAsRead(it, currentTime, true)
storage.markConversationAsRead(threadId, currentTime, true)
} }
return null return null
} }
@ -59,8 +58,6 @@ class MarkReadReceiver : BroadcastReceiver() {
context: Context, context: Context,
markedReadMessages: List<MarkedMessageInfo> markedReadMessages: List<MarkedMessageInfo>
) { ) {
Log.d(TAG, "process() called with: markedReadMessages = $markedReadMessages")
if (markedReadMessages.isEmpty()) return if (markedReadMessages.isEmpty()) return
sendReadReceipts(context, markedReadMessages) sendReadReceipts(context, markedReadMessages)
@ -131,8 +128,6 @@ class MarkReadReceiver : BroadcastReceiver() {
context: Context, context: Context,
hashToMessage: Map<String, MarkedMessageInfo> hashToMessage: Map<String, MarkedMessageInfo>
) { ) {
Log.d(TAG, "fetchUpdatedExpiriesAndScheduleDeletion() called with: context = $context, hashToMessage = $hashToMessage")
@Suppress("UNCHECKED_CAST") @Suppress("UNCHECKED_CAST")
val expiries = SnodeAPI.getExpiries(hashToMessage.keys.toList(), TextSecurePreferences.getLocalNumber(context)!!).get()["expiries"] as Map<String, Long> val expiries = SnodeAPI.getExpiries(hashToMessage.keys.toList(), TextSecurePreferences.getLocalNumber(context)!!).get()["expiries"] as Map<String, Long>
hashToMessage.forEach { (hash, info) -> expiries[hash]?.let { scheduleDeletion(context, info.expirationInfo, it - info.expirationInfo.expireStarted) } } hashToMessage.forEach { (hash, info) -> expiries[hash]?.let { scheduleDeletion(context, info.expirationInfo, it - info.expirationInfo.expireStarted) } }
@ -143,8 +138,6 @@ class MarkReadReceiver : BroadcastReceiver() {
expirationInfo: ExpirationInfo, expirationInfo: ExpirationInfo,
expiresIn: Long = expirationInfo.expiresIn expiresIn: Long = expirationInfo.expiresIn
) { ) {
Log.d(TAG, "MarkReadReceiver#scheduleDeletion() called with: expirationInfo = $expirationInfo, expiresIn = $expiresIn")
if (expiresIn == 0L) return if (expiresIn == 0L) return
val now = nowWithOffset val now = nowWithOffset