wip: add more logs for initial last Read sync of communities

This commit is contained in:
0x330a
2023-06-27 18:18:16 +10:00
parent dd001640a4
commit a15842166c
3 changed files with 14 additions and 0 deletions

View File

@@ -40,6 +40,7 @@ class BackgroundGroupAddJob(val joinUrl: String): Job {
}
storage.addOpenGroup(openGroup.joinUrl())
Log.d(KEY, "onOpenGroupAdded(${openGroup.server})")
Log.d("Loki-DBG", "added group $joinUrl")
storage.onOpenGroupAdded(openGroup.server, openGroup.room)
} catch (e: Exception) {
Log.e("OpenGroupDispatcher", "Failed to add group because",e)

View File

@@ -147,6 +147,9 @@ class BatchMessageReceiveJob(
val messageIds = linkedMapOf<Long, Pair<Boolean, Boolean>>()
val myLastSeen = storage.getLastSeen(threadId)
var newLastSeen = if (myLastSeen == -1L) 0 else myLastSeen
if (!openGroupID.isNullOrEmpty()) {
Log.d("Loki-DBG", "pre-lastSeen for: $openGroupID is $newLastSeen")
}
messages.forEach { (parameters, message, proto) ->
try {
when (message) {
@@ -217,9 +220,15 @@ class BatchMessageReceiveJob(
// 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).let { if (it == -1L) 0 else it }
if (!openGroupID.isNullOrEmpty()) {
Log.d("Loki-DBG", "current-lastSeen (w/ my message read) for: $openGroupID is $currentLastSeen")
}
if (currentLastSeen > newLastSeen) {
newLastSeen = currentLastSeen
}
if (!openGroupID.isNullOrEmpty()) {
Log.d("Loki-DBG", "new-lastSeen for: $openGroupID is $currentLastSeen")
}
storage.markConversationAsRead(threadId, newLastSeen)
storage.updateThread(threadId, true)
SSKEnvironment.shared.notificationManager.updateNotification(context, threadId)