From 78f9fbadb7a9cb79b3451b3c9dfe235c15fe7ded Mon Sep 17 00:00:00 2001 From: Ida Delphine Date: Fri, 24 Apr 2026 00:22:03 +0100 Subject: [PATCH 1/2] fix app crash on loading comment with no internet --- .../schabi/newpipe/paging/CommentsSource.kt | 11 ++++++---- .../video/comment/CommentSection.kt | 22 +++++++++++++++++++ 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/paging/CommentsSource.kt b/app/src/main/java/org/schabi/newpipe/paging/CommentsSource.kt index 20d67a283ab..ac590c72407 100644 --- a/app/src/main/java/org/schabi/newpipe/paging/CommentsSource.kt +++ b/app/src/main/java/org/schabi/newpipe/paging/CommentsSource.kt @@ -20,11 +20,14 @@ class CommentsSource(private val commentInfo: CommentInfo) : PagingSource Date: Fri, 24 Apr 2026 07:44:34 +0100 Subject: [PATCH 2/2] refactor if statements to when block --- .../video/comment/CommentSection.kt | 43 +++++++++++-------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/ui/components/video/comment/CommentSection.kt b/app/src/main/java/org/schabi/newpipe/ui/components/video/comment/CommentSection.kt index e2200b3fc54..b26457d1e29 100644 --- a/app/src/main/java/org/schabi/newpipe/ui/components/video/comment/CommentSection.kt +++ b/app/src/main/java/org/schabi/newpipe/ui/components/video/comment/CommentSection.kt @@ -141,25 +141,34 @@ private fun CommentSection( } // handle append (next page) errors - if (comments.loadState.append is LoadState.Error) { - item { - ErrorPanel( - errorInfo = ErrorInfo( - throwable = (comments.loadState.append as LoadState.Error).error, - userAction = UserAction.REQUESTED_COMMENTS, - request = "comments" - ), - onRetry = { comments.retry() }, - modifier = Modifier.fillMaxWidth() - ) + when (comments.loadState.append) { + is LoadState.Error -> { + item { + ErrorPanel( + errorInfo = ErrorInfo( + throwable = (comments.loadState.append as LoadState.Error).error, + userAction = UserAction.REQUESTED_COMMENTS, + request = "comments" + ), + onRetry = { comments.retry() }, + modifier = Modifier.fillMaxWidth() + ) + } } - } -// - // show loading indicator while appending - if (comments.loadState.append is LoadState.Loading) { - item { - LoadingIndicator(modifier = Modifier.padding(top = 8.dp)) + + // show loading indicator while appending + is LoadState.Loading -> { + item { + LoadingIndicator( + modifier = Modifier.padding( + top = 8.dp, + bottom = 8.dp + ) + ) + } } + + else -> {} } } }