Skip to content

Commit 75b8e66

Browse files
cmonfortepCDRussell
authored andcommitted
cancel observer after user imports
1 parent e7f0dc9 commit 75b8e66

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

autofill/autofill-impl/src/main/java/com/duckduckgo/autofill/impl/importing/promo/ImportInPasswordsVisibility.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import com.squareup.anvil.annotations.ContributesBinding
2828
import dagger.SingleInstanceIn
2929
import javax.inject.Inject
3030
import kotlinx.coroutines.CoroutineScope
31+
import kotlinx.coroutines.Job
3132
import kotlinx.coroutines.flow.collect
3233
import kotlinx.coroutines.launch
3334
import logcat.logcat
@@ -48,9 +49,10 @@ class RealImportInPasswordsVisibility @Inject constructor(
4849
) : ImportInPasswordsVisibility {
4950

5051
private var canShowImportPasswords = false
52+
private var importedPasswordsCollector: Job? = null
5153

5254
init {
53-
appCoroutineScope.launch(dispatcherProvider.io()) {
55+
importedPasswordsCollector = appCoroutineScope.launch(dispatcherProvider.io()) {
5456
logcat { "Autofill: Evaluating if user can show import promo" }
5557
canShowImportPasswords = evaluateIfUserCanShowImportPromo()
5658
logcat { "Autofill: Evaluation result, can show import promo? $canShowImportPasswords" }
@@ -63,6 +65,7 @@ class RealImportInPasswordsVisibility @Inject constructor(
6365
if (hasImported) {
6466
canShowImportPasswords = false
6567
logcat { "Autofill: User has imported passwords, hiding promo" }
68+
importedPasswordsCollector?.cancel()
6669
}
6770
}
6871
}

0 commit comments

Comments
 (0)