diff options
author | 2024-02-18 00:57:23 +0000 | |
---|---|---|
committer | 2024-02-18 00:57:23 +0000 | |
commit | cb295796fbbcb96686475f7631a029209d2d9474 (patch) | |
tree | 67e70c1597b1f827f2a97a38811f651bfa2fbbe8 /java/src | |
parent | 87aeb10a63dea6f47aa66eff8ef2da8b5814223c (diff) | |
parent | eb2c6935518e781ca0651bca69ddb2e306daa05a (diff) |
Merge "Change UserInteractor availability interface" into main
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/com/android/intentresolver/v2/domain/interactor/UserInteractor.kt | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/java/src/com/android/intentresolver/v2/domain/interactor/UserInteractor.kt b/java/src/com/android/intentresolver/v2/domain/interactor/UserInteractor.kt index c8df9684..72b604c2 100644 --- a/java/src/com/android/intentresolver/v2/domain/interactor/UserInteractor.kt +++ b/java/src/com/android/intentresolver/v2/domain/interactor/UserInteractor.kt @@ -26,9 +26,7 @@ import com.android.intentresolver.v2.shared.model.User.Role import javax.inject.Inject import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.combine -import kotlinx.coroutines.flow.firstOrNull import kotlinx.coroutines.flow.map -import kotlinx.coroutines.flow.mapNotNull /** The high level User interface. */ class UserInteractor @@ -67,20 +65,16 @@ constructor( it.primary.id == launchedAs.identifier || it.clone?.id == launchedAs.identifier } } - /** - * Provides a flow to report on the availability of the profile. An unavailable profile may be + * Provides a flow to report on the availability of profile. An unavailable profile may be * hidden or appear disabled within the app. */ - fun isAvailable(type: Type): Flow<Boolean> { - val profileFlow = profiles.map { list -> list.firstOrNull { it.type == type } } - return combine(profileFlow, userRepository.availability) { profile, availability -> - when (profile) { - null -> false - else -> availability.getOrDefault(profile.primary, false) + val availability: Flow<Map<Profile, Boolean>> = + combine(profiles, userRepository.availability) { profiles, availability -> + profiles.associateWith { + availability.getOrDefault(it.primary, false) } } - } /** * Request the profile state be updated. In the case of enabling, the operation could take |