feat: add provider login flow #4
+22
-9
@@ -48,17 +48,30 @@ class AppSessionViewModel @Inject constructor(
|
||||
|
||||
init {
|
||||
viewModelScope.launch {
|
||||
val activeProfile = profileStore.activeProfile()
|
||||
if (activeProfile != null && availability.forType(activeProfile.type) is Availability.Disabled) {
|
||||
coordinator.switchProvider()
|
||||
try {
|
||||
val activeProfile = profileStore.activeProfile()
|
||||
if (activeProfile != null && availability.forType(activeProfile.type) is Availability.Disabled) {
|
||||
coordinator.switchProvider()
|
||||
bootstrapResult.value = ProviderBootstrapResult(
|
||||
profileId = null,
|
||||
result = DomainResult.Success(null),
|
||||
)
|
||||
} else {
|
||||
bootstrapResult.value = ProviderBootstrapResult(
|
||||
profileId = activeProfile?.id,
|
||||
result = coordinator.bootstrap(),
|
||||
)
|
||||
}
|
||||
} catch (error: kotlinx.coroutines.CancellationException) {
|
||||
throw error
|
||||
} catch (error: Exception) {
|
||||
bootstrapResult.value = ProviderBootstrapResult(
|
||||
profileId = null,
|
||||
result = DomainResult.Success(null),
|
||||
)
|
||||
} else {
|
||||
bootstrapResult.value = ProviderBootstrapResult(
|
||||
profileId = activeProfile?.id,
|
||||
result = coordinator.bootstrap(),
|
||||
result = DomainResult.Failure(
|
||||
com.flagship.abox.manager.domain.DomainError.Unknown(
|
||||
detail = error.message ?: "Unable to load provider settings",
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user