Merge branch 'dev' into onion-requests-2

This commit is contained in:
nielsandriesse 2020-10-27 11:12:42 +11:00
commit 4c81f4f197
2 changed files with 10 additions and 7 deletions

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; polling 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)

View file

@ -24,8 +24,8 @@ class PublicChatManager(private val context: Context) {
var areAllCaughtUp = true
refreshChatsAndPollers()
for ((threadID, chat) in chats) {
val poller = pollers[threadID] ?: PublicChatPoller(context, chat)
areAllCaughtUp = areAllCaughtUp && poller.isCaughtUp
val poller = pollers[threadID]
areAllCaughtUp = if (poller != null) areAllCaughtUp && poller.isCaughtUp else true
}
return areAllCaughtUp
}