Skip to content

Commit 188ba0a

Browse files
committed
refactor if statements to when block
1 parent 78f9fba commit 188ba0a

1 file changed

Lines changed: 26 additions & 17 deletions

File tree

app/src/main/java/org/schabi/newpipe/ui/components/video/comment/CommentSection.kt

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -141,25 +141,34 @@ private fun CommentSection(
141141
}
142142

143143
// handle append (next page) errors
144-
if (comments.loadState.append is LoadState.Error) {
145-
item {
146-
ErrorPanel(
147-
errorInfo = ErrorInfo(
148-
throwable = (comments.loadState.append as LoadState.Error).error,
149-
userAction = UserAction.REQUESTED_COMMENTS,
150-
request = "comments"
151-
),
152-
onRetry = { comments.retry() },
153-
modifier = Modifier.fillMaxWidth()
154-
)
144+
when (comments.loadState.append) {
145+
is LoadState.Error -> {
146+
item {
147+
ErrorPanel(
148+
errorInfo = ErrorInfo(
149+
throwable = (comments.loadState.append as LoadState.Error).error,
150+
userAction = UserAction.REQUESTED_COMMENTS,
151+
request = "comments"
152+
),
153+
onRetry = { comments.retry() },
154+
modifier = Modifier.fillMaxWidth()
155+
)
156+
}
155157
}
156-
}
157-
//
158-
// show loading indicator while appending
159-
if (comments.loadState.append is LoadState.Loading) {
160-
item {
161-
LoadingIndicator(modifier = Modifier.padding(top = 8.dp))
158+
159+
// show loading indicator while appending
160+
is LoadState.Loading -> {
161+
item {
162+
LoadingIndicator(
163+
modifier = Modifier.padding(
164+
top = 8.dp,
165+
bottom = 8.dp
166+
)
167+
)
168+
}
162169
}
170+
171+
else -> {}
163172
}
164173
}
165174
}

0 commit comments

Comments
 (0)