Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merging master to develop #45

Merged
merged 2 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
*.iml
.gradle
/local.properties
/.idea
.DS_Store
build/
/captures
Expand All @@ -14,3 +13,4 @@ iosApp/iosApp.xcworkspace/*
iosApp/iosApp.xcodeproj/*
!iosApp/iosApp.xcodeproj/project.pbxproj
shared/shared.podspec
androidApp/build/*
7 changes: 4 additions & 3 deletions shared/src/commonMain/kotlin/ui/MainViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import data.model.Article
import data.repository.NewsRepository
import data.util.Sources
import data.util.asResult
import data.util.Result.*
import dev.icerock.moko.mvvm.viewmodel.ViewModel
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
Expand All @@ -21,9 +22,9 @@ class MainViewModel(
.asResult()
.map { result ->
when (result) {
is data.util.Result.Loading -> TopHeadlinesState.Loading
is data.util.Result.Success -> TopHeadlinesState.Success(result.data.articles)
is data.util.Result.Error -> {
is Loading -> TopHeadlinesState.Loading
is Success -> TopHeadlinesState.Success(result.data.articles)
is Error -> {
TopHeadlinesState.Error(result.exception?.message ?: "Unknown error")
}
}
Expand Down
Loading