Fix merge

This commit is contained in:
Niels Andriesse 2021-05-24 16:21:24 +10:00
parent ba116df195
commit 5d9957a57d
5 changed files with 9 additions and 12 deletions

View File

@ -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)
}

View File

@ -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 }

View File

@ -68,8 +68,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));
} else {

View File

@ -44,7 +44,7 @@ interface StorageProtocol {
fun getAllPendingJobs(type: String): Map<String,Job?>
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

View File

@ -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<Long>) {