mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-14 12:57:04 +05:30
refactor(common): ensure comments page can handle errors
This commit is contained in:
parent
e96ef78d1a
commit
f69c569406
1 changed files with 5 additions and 1 deletions
|
@ -73,7 +73,11 @@ fun CommentsPage(
|
||||||
) {
|
) {
|
||||||
val postDetails by
|
val postDetails by
|
||||||
produceState<NetworkState>(NetworkState.Loading) {
|
produceState<NetworkState>(NetworkState.Loading) {
|
||||||
value = NetworkState.Success(getDetails(postId))
|
runCatching { getDetails(postId) }
|
||||||
|
.fold(
|
||||||
|
onSuccess = { details -> value = NetworkState.Success(details) },
|
||||||
|
onFailure = { value = NetworkState.Error("Failed to load comments") }
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
when (postDetails) {
|
when (postDetails) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue