From feb6cfdecbcda45239b03b6c94da2f36e2e33870 Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Mon, 19 Aug 2019 16:33:56 +1000 Subject: [PATCH] Fix ANR --- .../thoughtcrime/securesms/loki/BackgroundPollWorker.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/org/thoughtcrime/securesms/loki/BackgroundPollWorker.kt b/src/org/thoughtcrime/securesms/loki/BackgroundPollWorker.kt index d380be3f1f..fa110320f6 100644 --- a/src/org/thoughtcrime/securesms/loki/BackgroundPollWorker.kt +++ b/src/org/thoughtcrime/securesms/loki/BackgroundPollWorker.kt @@ -2,6 +2,7 @@ package org.thoughtcrime.securesms.loki import android.content.Context import android.content.Intent +import nl.komponents.kovenant.functional.map import org.thoughtcrime.securesms.database.DatabaseFactory import org.thoughtcrime.securesms.jobs.PushContentReceiveJob import org.thoughtcrime.securesms.service.PersistentAlarmManagerListener @@ -30,8 +31,10 @@ class BackgroundPollWorker : PersistentAlarmManagerListener() { val userHexEncodedPublicKey = TextSecurePreferences.getLocalNumber(context) val lokiAPIDatabase = DatabaseFactory.getLokiAPIDatabase(context) try { - LokiAPI(userHexEncodedPublicKey, lokiAPIDatabase).getMessages().get().forEach { - PushContentReceiveJob(context).processEnvelope(SignalServiceEnvelope(it)) + LokiAPI(userHexEncodedPublicKey, lokiAPIDatabase).getMessages().map { messages -> + messages.forEach { + PushContentReceiveJob(context).processEnvelope(SignalServiceEnvelope(it)) + } } } catch (exception: Throwable) { // Do nothing