From a4a5f410971f9f5fc836cf6bd6d1604a547cdaeb Mon Sep 17 00:00:00 2001 From: Javinator9889 Date: Wed, 22 Apr 2020 17:49:03 +0200 Subject: [PATCH] Timeout while waiting for FA instantiation and updated changelog For performance reasons, if the FA instantiation takes more than 10 seconds then the "await" instruction will fail (return null). In this way we can ensure that the notification will be published --- CHANGELOG | 3 +++ .../jobs/workers/AbstractNotificationsWorker.kt | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 2b660be..c4da86b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +## v1.1.1 ++ New notifications handler - now they must notify when expected + ## v1.1.0 + NEW: OkHttp for handling file downloading. + Corrected a minor bug while displaying images. diff --git a/app/src/main/java/com/javinator9889/handwashingreminder/jobs/workers/AbstractNotificationsWorker.kt b/app/src/main/java/com/javinator9889/handwashingreminder/jobs/workers/AbstractNotificationsWorker.kt index 6d5734a..29f7136 100644 --- a/app/src/main/java/com/javinator9889/handwashingreminder/jobs/workers/AbstractNotificationsWorker.kt +++ b/app/src/main/java/com/javinator9889/handwashingreminder/jobs/workers/AbstractNotificationsWorker.kt @@ -33,6 +33,7 @@ import com.javinator9889.handwashingreminder.utils.runAt import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.withContext +import kotlinx.coroutines.withTimeoutOrNull import timber.log.Timber import java.util.concurrent.TimeUnit @@ -75,7 +76,9 @@ abstract class AbstractNotificationsWorker( override suspend fun doWork(): Result = coroutineScope { with(HandwashingApplication.getInstance()) { - firebaseInitDeferred.await() + withTimeoutOrNull(10_000L) { + firebaseInitDeferred.await() + } } shouldScheduleNext = true var data: Data? = null