From 5d9957a57d309c41b5b2e0a91324549e0e7fab64 Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Mon, 24 May 2021 16:21:24 +1000 Subject: [PATCH] Fix merge --- .../java/org/thoughtcrime/securesms/database/Storage.kt | 2 +- .../thoughtcrime/securesms/loki/api/OpenGroupManager.kt | 8 ++++---- .../securesms/notifications/OptimizedMessageNotifier.java | 2 -- .../org/session/libsession/database/StorageProtocol.kt | 2 +- .../sending_receiving/pollers/OpenGroupPollerV2.kt | 7 +++---- 5 files changed, 9 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/Storage.kt b/app/src/main/java/org/thoughtcrime/securesms/database/Storage.kt index 6b335dca58..5f498fa100 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/database/Storage.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/database/Storage.kt @@ -188,7 +188,7 @@ class Storage(context: Context, helper: SQLCipherOpenHelper) : Database(context, return DatabaseFactory.getSessionJobDatabase(context).getMessageSendJob(messageSendJobID) } - override fun getMessageReceivedJob(messageReceiveJobID: String): MessageReceiveJob? { + override fun getMessageReceiveJob(messageReceiveJobID: String): MessageReceiveJob? { return DatabaseFactory.getSessionJobDatabase(context).getMessageReceiveJob(messageReceiveJobID) } diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/api/OpenGroupManager.kt b/app/src/main/java/org/thoughtcrime/securesms/loki/api/OpenGroupManager.kt index b9d0f52c9e..a5ab5d0b9d 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/api/OpenGroupManager.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/loki/api/OpenGroupManager.kt @@ -23,13 +23,13 @@ object OpenGroupManager { val isAllCaughtUp: Boolean get() { pollers.values.forEach { poller -> - val jobID = poller.secondLastJob?.id + val jobID = poller.secondToLastJob?.id jobID?.let { val storage = MessagingModuleConfiguration.shared.storage - if (storage.getMessageReceivedJob(jobID) == null) { - // If the second last job is done, it means we are now handling the last job + if (storage.getMessageReceiveJob(jobID) == null) { + // If the second to last job is done, it means we are now handling the last job poller.isCaughtUp = true - poller.secondLastJob = null + poller.secondToLastJob = null } } if (!poller.isCaughtUp) { return false } diff --git a/app/src/main/java/org/thoughtcrime/securesms/notifications/OptimizedMessageNotifier.java b/app/src/main/java/org/thoughtcrime/securesms/notifications/OptimizedMessageNotifier.java index d60d40b208..aac737add2 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/notifications/OptimizedMessageNotifier.java +++ b/app/src/main/java/org/thoughtcrime/securesms/notifications/OptimizedMessageNotifier.java @@ -67,8 +67,6 @@ public class OptimizedMessageNotifier implements MessageNotifier { } isCaughtUp = isCaughtUp && OpenGroupManager.INSTANCE.isAllCaughtUp(); - - Log.d("Ryan", "Is caught up? " + isCaughtUp); if (isCaughtUp) { performOnBackgroundThreadIfNeeded(() -> wrapped.updateNotification(context, threadId)); diff --git a/libsession/src/main/java/org/session/libsession/database/StorageProtocol.kt b/libsession/src/main/java/org/session/libsession/database/StorageProtocol.kt index f18dcc7a43..00b856d809 100644 --- a/libsession/src/main/java/org/session/libsession/database/StorageProtocol.kt +++ b/libsession/src/main/java/org/session/libsession/database/StorageProtocol.kt @@ -44,7 +44,7 @@ interface StorageProtocol { fun getAllPendingJobs(type: String): Map fun getAttachmentUploadJob(attachmentID: Long): AttachmentUploadJob? fun getMessageSendJob(messageSendJobID: String): MessageSendJob? - fun getMessageReceivedJob(messageReceiveJobID: String): MessageReceiveJob? + fun getMessageReceiveJob(messageReceiveJobID: String): MessageReceiveJob? fun resumeMessageSendJobIfNeeded(messageSendJobID: String) fun isJobCanceled(job: Job): Boolean diff --git a/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/pollers/OpenGroupPollerV2.kt b/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/pollers/OpenGroupPollerV2.kt index 51ac9e6e6f..4b9c9a7071 100644 --- a/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/pollers/OpenGroupPollerV2.kt +++ b/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/pollers/OpenGroupPollerV2.kt @@ -19,7 +19,7 @@ import java.util.concurrent.TimeUnit class OpenGroupPollerV2(private val server: String, private val executorService: ScheduledExecutorService?) { var hasStarted = false var isCaughtUp = false - var secondLastJob: MessageReceiveJob? = null + var secondToLastJob: MessageReceiveJob? = null private var future: ScheduledFuture<*>? = null companion object { @@ -46,7 +46,7 @@ class OpenGroupPollerV2(private val server: String, private val executorService: val openGroupID = "$server.$room" handleNewMessages(openGroupID, response.messages, isBackgroundPoll) handleDeletedMessages(openGroupID, response.deletions) - if (secondLastJob == null && !isCaughtUp) { + if (secondToLastJob == null && !isCaughtUp) { isCaughtUp = true } } @@ -74,7 +74,7 @@ class OpenGroupPollerV2(private val server: String, private val executorService: } else { JobQueue.shared.add(job) if (!isCaughtUp) { - secondLastJob = latestJob + secondToLastJob = latestJob } latestJob = job } @@ -82,7 +82,6 @@ class OpenGroupPollerV2(private val server: String, private val executorService: Log.e("Loki", "Exception parsing message", e) } } - Log.d("Ryan", "Finish a round of polling in thread $openGroupID") } private fun handleDeletedMessages(openGroupID: String, deletedMessageServerIDs: List) {