fix: finally fix the darn unread count issue by

This commit is contained in:
0x330a
2023-05-01 14:39:17 +10:00
parent ac736744f6
commit 216070fa5d
8 changed files with 43 additions and 17 deletions

View File

@@ -155,7 +155,8 @@ class BatchMessageReceiveJob(
// The LinkedHashMap should preserve insertion order
val messageIds = linkedMapOf<Long, Pair<Boolean, Boolean>>()
val myLastSeen = storage.getLastSeen(threadId)
var newLastSeen = myLastSeen
var newLastSeen = if (myLastSeen == -1L) 0 else myLastSeen
Log.d("Loki-DBG", "myLastSeen = $newLastSeen")
messages.forEach { (parameters, message, proto) ->
try {
when (message) {
@@ -224,10 +225,12 @@ class BatchMessageReceiveJob(
// increment unreads, notify, and update thread
// last seen will be the current last seen if not changed (re-computes the read counts for thread record)
// might have been updated from a different thread at this point
val currentLastSeen = storage.getLastSeen(threadId)
val currentLastSeen = storage.getLastSeen(threadId).let { if (it == -1L) 0 else it }
Log.d("Loki-DBG", "currentLastSeen = $currentLastSeen")
if (currentLastSeen > newLastSeen) {
newLastSeen = currentLastSeen
}
Log.d("Loki-DBG", "newLastSeen = $newLastSeen")
storage.markConversationAsRead(threadId, newLastSeen)
storage.updateThread(threadId, true)
SSKEnvironment.shared.notificationManager.updateNotification(context, threadId)