mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-25 01:07:47 +00:00
Debug background polling
This commit is contained in:
parent
2ee8bd8959
commit
34a35e2d77
@ -254,6 +254,7 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc
|
||||
messageNotifier.setVisibleThread(-1);
|
||||
// Loki
|
||||
if (poller != null) { poller.stopIfNeeded(); }
|
||||
if (closedGroupPoller != null) { closedGroupPoller.stopIfNeeded(); }
|
||||
if (publicChatManager != null) { publicChatManager.stopPollers(); }
|
||||
}
|
||||
|
||||
@ -534,6 +535,7 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc
|
||||
public void stopPolling() {
|
||||
if (poller != null) { poller.stopIfNeeded(); }
|
||||
if (closedGroupPoller != null) { closedGroupPoller.stopIfNeeded(); }
|
||||
if (publicChatManager != null) { publicChatManager.stopPollers(); }
|
||||
}
|
||||
|
||||
private void resubmitProfilePictureIfNeeded() {
|
||||
|
@ -1,7 +1,9 @@
|
||||
package org.thoughtcrime.securesms.loki.api
|
||||
|
||||
import android.content.Context
|
||||
import kotlinx.coroutines.awaitAll
|
||||
import nl.komponents.kovenant.Promise
|
||||
import nl.komponents.kovenant.all
|
||||
import nl.komponents.kovenant.functional.map
|
||||
import org.thoughtcrime.securesms.ApplicationContext
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||
@ -45,6 +47,7 @@ class BackgroundPollJob private constructor(parameters: Parameters) : BaseJob(pa
|
||||
|
||||
public override fun onRun() {
|
||||
try {
|
||||
Log.d("Loki", "Performing background poll.")
|
||||
val userPublicKey = TextSecurePreferences.getLocalNumber(context)
|
||||
val promises = mutableListOf<Promise<Unit, Exception>>()
|
||||
val promise = SnodeAPI.shared.getMessages(userPublicKey).map { envelopes ->
|
||||
@ -60,6 +63,7 @@ class BackgroundPollJob private constructor(parameters: Parameters) : BaseJob(pa
|
||||
poller.stop()
|
||||
promises.add(poller.pollForNewMessages())
|
||||
}
|
||||
all(promises).get()
|
||||
} catch (exception: Exception) {
|
||||
Log.d("Loki", "Background poll failed due to error: $exception.")
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user