Skip to content

Commit

Permalink
Timeout while waiting for FA instantiation and updated changelog
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Javinator9889 committed Apr 22, 2020
1 parent 4deb319 commit a4a5f41
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions 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.
Expand Down
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a4a5f41

Please sign in to comment.