mirror of
				https://github.com/TeamNewPipe/NewPipe
				synced 2025-10-31 15:23:00 +00:00 
			
		
		
		
	Better handle unknown values for comment & like count
This commit is contained in:
		| @@ -135,26 +135,28 @@ fun Comment(comment: CommentsInfoItem) { | ||||
|                     verticalAlignment = Alignment.CenterVertically, | ||||
|                     modifier = Modifier.padding(start = 1.dp, top = 6.dp, end = 4.dp, bottom = 6.dp) | ||||
|                 ) { | ||||
|                     Image( | ||||
|                         painter = painterResource(R.drawable.ic_thumb_up), | ||||
|                         contentDescription = stringResource(R.string.detail_likes_img_view_description), | ||||
|                         modifier = Modifier | ||||
|                             .padding(end = 4.dp) | ||||
|                             .size(20.dp), | ||||
|                     ) | ||||
|                     Text( | ||||
|                         text = Localization.likeCount(context, comment.likeCount), | ||||
|                         maxLines = 1, | ||||
|                         style = MaterialTheme.typography.labelMedium, | ||||
|                     ) | ||||
|                     // do not show anything if the like count is unknown | ||||
|                     if (comment.likeCount >= 0) { | ||||
|                         Image( | ||||
|                             painter = painterResource(R.drawable.ic_thumb_up), | ||||
|                             contentDescription = stringResource(R.string.detail_likes_img_view_description), | ||||
|                             modifier = Modifier | ||||
|                                 .padding(end = 4.dp) | ||||
|                                 .size(20.dp), | ||||
|                         ) | ||||
|                         Text( | ||||
|                             text = Localization.likeCount(context, comment.likeCount), | ||||
|                             maxLines = 1, | ||||
|                             style = MaterialTheme.typography.labelMedium, | ||||
|                             modifier = Modifier.padding(end = 8.dp) | ||||
|                         ) | ||||
|                     } | ||||
|  | ||||
|                     if (comment.isHeartedByUploader) { | ||||
|                         Image( | ||||
|                             painter = painterResource(R.drawable.ic_heart), | ||||
|                             contentDescription = stringResource(R.string.detail_heart_img_view_description), | ||||
|                             modifier = Modifier | ||||
|                                 .padding(start = 8.dp) | ||||
|                                 .size(20.dp), | ||||
|                             modifier = Modifier.size(20.dp), | ||||
|                         ) | ||||
|                     } | ||||
|                 } | ||||
|   | ||||
| @@ -6,7 +6,9 @@ import androidx.compose.foundation.lazy.LazyColumn | ||||
| import androidx.compose.foundation.lazy.rememberLazyListState | ||||
| import androidx.compose.material3.ExperimentalMaterial3Api | ||||
| import androidx.compose.material3.HorizontalDivider | ||||
| import androidx.compose.material3.MaterialTheme | ||||
| import androidx.compose.material3.ModalBottomSheet | ||||
| import androidx.compose.material3.Text | ||||
| import androidx.compose.runtime.Composable | ||||
| import androidx.compose.runtime.remember | ||||
| import androidx.compose.runtime.rememberCoroutineScope | ||||
| @@ -14,6 +16,7 @@ import androidx.compose.ui.Modifier | ||||
| import androidx.compose.ui.graphics.Color | ||||
| import androidx.compose.ui.input.nestedscroll.nestedScroll | ||||
| import androidx.compose.ui.platform.rememberNestedScrollInteropConnection | ||||
| import androidx.compose.ui.res.pluralStringResource | ||||
| import androidx.compose.ui.tooling.preview.Preview | ||||
| import androidx.compose.ui.unit.dp | ||||
| import androidx.paging.LoadState | ||||
| @@ -78,7 +81,7 @@ private fun CommentRepliesDialog( | ||||
|                     CommentRepliesHeader(comment = parentComment) | ||||
|                     HorizontalDivider( | ||||
|                         thickness = 1.dp, | ||||
|                         modifier = Modifier.padding(start = 24.dp, end = 24.dp, bottom = 8.dp) | ||||
|                         modifier = Modifier.padding(start = 16.dp, end = 16.dp, bottom = 8.dp) | ||||
|                     ) | ||||
|                 } | ||||
|  | ||||
| @@ -97,6 +100,18 @@ private fun CommentRepliesDialog( | ||||
|                         } | ||||
|                     } | ||||
|                 } else { | ||||
|                     if (comments.itemCount >= 0) { | ||||
|                         item { | ||||
|                             Text( | ||||
|                                 modifier = Modifier.padding(horizontal = 12.dp, vertical = 4.dp), | ||||
|                                 text = pluralStringResource( | ||||
|                                     R.plurals.replies, comments.itemCount, comments.itemCount | ||||
|                                 ), | ||||
|                                 maxLines = 1, | ||||
|                                 style = MaterialTheme.typography.titleMedium | ||||
|                             ) | ||||
|                         } | ||||
|                     } | ||||
|                     items(comments.itemCount) { | ||||
|                         Comment(comment = comments[it]!!) | ||||
|                     } | ||||
|   | ||||
| @@ -83,14 +83,17 @@ fun CommentRepliesHeader(comment: CommentsInfoItem) { | ||||
|                 horizontalArrangement = Arrangement.spacedBy(8.dp), | ||||
|                 verticalAlignment = Alignment.CenterVertically | ||||
|             ) { | ||||
|                 Image( | ||||
|                     painter = painterResource(R.drawable.ic_thumb_up), | ||||
|                     contentDescription = stringResource(R.string.detail_likes_img_view_description) | ||||
|                 ) | ||||
|                 Text( | ||||
|                     text = Localization.likeCount(context, comment.likeCount), | ||||
|                     maxLines = 1, | ||||
|                 ) | ||||
|                 // do not show anything if the like count is unknown | ||||
|                 if (comment.likeCount >= 0) { | ||||
|                     Image( | ||||
|                         painter = painterResource(R.drawable.ic_thumb_up), | ||||
|                         contentDescription = stringResource(R.string.detail_likes_img_view_description) | ||||
|                     ) | ||||
|                     Text( | ||||
|                         text = Localization.likeCount(context, comment.likeCount), | ||||
|                         maxLines = 1, | ||||
|                     ) | ||||
|                 } | ||||
|  | ||||
|                 if (comment.isHeartedByUploader) { | ||||
|                     Image( | ||||
|   | ||||
| @@ -14,7 +14,6 @@ import androidx.compose.ui.graphics.Color | ||||
| import androidx.compose.ui.input.nestedscroll.nestedScroll | ||||
| import androidx.compose.ui.platform.rememberNestedScrollInteropConnection | ||||
| import androidx.compose.ui.res.pluralStringResource | ||||
| import androidx.compose.ui.text.font.FontWeight | ||||
| import androidx.compose.ui.tooling.preview.Preview | ||||
| import androidx.compose.ui.unit.dp | ||||
| import androidx.lifecycle.compose.collectAsStateWithLifecycle | ||||
| @@ -84,12 +83,17 @@ private fun CommentSection( | ||||
|                                 NoItemsMessage(R.string.no_comments) | ||||
|                             } | ||||
|                         } else { | ||||
|                             item { | ||||
|                                 Text( | ||||
|                                     modifier = Modifier.padding(start = 8.dp), | ||||
|                                     text = pluralStringResource(R.plurals.comments, count, count), | ||||
|                                     fontWeight = FontWeight.Bold | ||||
|                                 ) | ||||
|                             // do not show anything if the comment count is unknown | ||||
|                             if (count >= 0) { | ||||
|                                 item { | ||||
|                                     Text( | ||||
|                                         modifier = Modifier | ||||
|                                             .padding(start = 12.dp, end = 12.dp, bottom = 4.dp), | ||||
|                                         text = pluralStringResource(R.plurals.comments, count, count), | ||||
|                                         maxLines = 1, | ||||
|                                         style = MaterialTheme.typography.titleMedium | ||||
|                                     ) | ||||
|                                 } | ||||
|                             } | ||||
|  | ||||
|                             when (comments.loadState.refresh) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Stypox
					Stypox