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