mirror of
				https://github.com/TeamNewPipe/NewPipe
				synced 2025-10-30 23:03:00 +00:00 
			
		
		
		
	Improve comment loading smoothness
This commit is contained in:
		| @@ -10,6 +10,9 @@ import androidx.compose.material3.MaterialTheme | ||||
| import androidx.compose.material3.Surface | ||||
| import androidx.compose.material3.Text | ||||
| import androidx.compose.runtime.Composable | ||||
| import androidx.compose.runtime.derivedStateOf | ||||
| import androidx.compose.runtime.getValue | ||||
| import androidx.compose.runtime.remember | ||||
| import androidx.compose.ui.Alignment | ||||
| import androidx.compose.ui.Modifier | ||||
| import androidx.compose.ui.res.stringResource | ||||
| @@ -39,7 +42,7 @@ fun CommentSection( | ||||
| ) { | ||||
|     Surface(color = MaterialTheme.colorScheme.background) { | ||||
|         val comments = commentsFlow.collectAsLazyPagingItems() | ||||
|         val refresh = comments.loadState.refresh | ||||
|         val itemCount by remember { derivedStateOf { comments.itemCount } } | ||||
|         val listState = rememberLazyListState() | ||||
|  | ||||
|         LazyColumnScrollbar(state = listState) { | ||||
| @@ -51,8 +54,9 @@ fun CommentSection( | ||||
|                     } | ||||
|                 } | ||||
|  | ||||
|                 if (comments.itemCount == 0) { | ||||
|                 if (itemCount == 0) { | ||||
|                     item { | ||||
|                         val refresh = comments.loadState.refresh | ||||
|                         if (refresh is LoadState.Loading) { | ||||
|                             LoadingIndicator(modifier = Modifier.padding(top = 8.dp)) | ||||
|                         } else { | ||||
| @@ -60,7 +64,7 @@ fun CommentSection( | ||||
|                         } | ||||
|                     } | ||||
|                 } else { | ||||
|                     items(comments.itemCount) { | ||||
|                     items(itemCount) { | ||||
|                         Comment(comment = comments[it]!!) | ||||
|                     } | ||||
|                 } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Isira Seneviratne
					Isira Seneviratne