Skip to content

Commit

Permalink
fix:#2448 Handle network error in HomeViewModel to emit error
Browse files Browse the repository at this point in the history
  • Loading branch information
SaiThanushreddy authored and therajanmaurya committed Jan 5, 2024
1 parent 53aa750 commit 212a23c
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,18 @@ class HomeViewModel @Inject constructor(private val homeRepositoryImp: HomeRepos
viewModelScope.launch {
_homeUiState.value = HomeUiState.Loading
homeRepositoryImp.clientAccounts().catch {
_homeUiState.value = HomeUiState.Error(R.string.error_fetching_accounts)
_homeUiState.value = HomeUiState.Error(R.string.no_internet_connection)
}.collect { clientAccounts ->
_homeUiState.value = HomeUiState.ClientAccountDetails(
getLoanAccountDetails(clientAccounts.loanAccounts),
getSavingAccountDetails(clientAccounts.savingsAccounts)
)

}
}
}


val userDetails: Unit
get() {
viewModelScope.launch {
Expand Down

0 comments on commit 212a23c

Please sign in to comment.