From 0d48b65a259793e950e68d63c16a40dffc309919 Mon Sep 17 00:00:00 2001 From: Jonathan Almeida Date: Tue, 3 Mar 2020 15:02:40 -0500 Subject: [PATCH] For #8950: Unregister observers in the main scope coroutine --- .../java/org/mozilla/fenix/push/PushFxaIntegration.kt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/mozilla/fenix/push/PushFxaIntegration.kt b/app/src/main/java/org/mozilla/fenix/push/PushFxaIntegration.kt index 3630eed8c..aa3f2846f 100644 --- a/app/src/main/java/org/mozilla/fenix/push/PushFxaIntegration.kt +++ b/app/src/main/java/org/mozilla/fenix/push/PushFxaIntegration.kt @@ -6,6 +6,7 @@ package org.mozilla.fenix.push import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.MainScope import kotlinx.coroutines.launch import mozilla.components.concept.sync.AccountObserver import mozilla.components.concept.sync.AuthType @@ -100,8 +101,10 @@ internal class OneTimePushMessageObserver( } } - // Remove ourselves when we're done. - pushFeature.unregister(this) + MainScope().launch { + // Remove ourselves when we're done. + pushFeature.unregister(this@OneTimePushMessageObserver) + } } } } @@ -122,6 +125,8 @@ internal class OneTimeMessageDeliveryObserver( it.processRawEventAsync(String(message)) } - lazyAccount.value.unregister(this) + MainScope().launch { + lazyAccount.value.unregister(this@OneTimeMessageDeliveryObserver) + } } }