disable background polling when FCM is on

This commit is contained in:
Ryan ZHAO 2020-10-27 10:03:32 +11:00
parent a959c02252
commit ae261ebd83

View File

@ -50,13 +50,16 @@ class BackgroundPollJob private constructor(parameters: Parameters) : BaseJob(pa
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 ->
envelopes.forEach {
PushContentReceiveJob(context).processEnvelope(SignalServiceEnvelope(it), false)
if (!TextSecurePreferences.isUsingFCM(context)) {
Log.d("Loki", "Not using FCM, poll for contacts and closed groups.")
val promise = SnodeAPI.shared.getMessages(userPublicKey).map { envelopes ->
envelopes.forEach {
PushContentReceiveJob(context).processEnvelope(SignalServiceEnvelope(it), false)
}
}
promises.add(promise)
promises.addAll(ClosedGroupPoller.shared.pollOnce())
}
promises.add(promise)
promises.addAll(ClosedGroupPoller.shared.pollOnce())
val openGroups = DatabaseFactory.getLokiThreadDatabase(context).getAllPublicChats().map { it.value }
for (openGroup in openGroups) {
val poller = PublicChatPoller(context, openGroup)