mirror of
				https://github.com/TeamNewPipe/NewPipe
				synced 2025-10-31 07:13:00 +00:00 
			
		
		
		
	Cache total duration calculation
This commit is contained in:
		| @@ -11,7 +11,9 @@ import androidx.compose.material3.MaterialTheme | |||||||
| import androidx.compose.material3.Surface | import androidx.compose.material3.Surface | ||||||
| import androidx.compose.runtime.Composable | import androidx.compose.runtime.Composable | ||||||
| import androidx.compose.runtime.collectAsState | import androidx.compose.runtime.collectAsState | ||||||
|  | import androidx.compose.runtime.derivedStateOf | ||||||
| import androidx.compose.runtime.getValue | import androidx.compose.runtime.getValue | ||||||
|  | import androidx.compose.runtime.remember | ||||||
| import androidx.compose.ui.platform.LocalContext | import androidx.compose.ui.platform.LocalContext | ||||||
| import androidx.compose.ui.tooling.preview.Preview | import androidx.compose.ui.tooling.preview.Preview | ||||||
| import androidx.compose.ui.unit.dp | import androidx.compose.ui.unit.dp | ||||||
| @@ -40,7 +42,11 @@ import org.schabi.newpipe.viewmodels.PlaylistViewModel | |||||||
| fun Playlist(playlistViewModel: PlaylistViewModel = viewModel()) { | fun Playlist(playlistViewModel: PlaylistViewModel = viewModel()) { | ||||||
|     val playlistInfo by playlistViewModel.playlistInfo.collectAsState() |     val playlistInfo by playlistViewModel.playlistInfo.collectAsState() | ||||||
|     val streams = playlistViewModel.streamItems.collectAsLazyPagingItems() |     val streams = playlistViewModel.streamItems.collectAsLazyPagingItems() | ||||||
|     val totalDuration = streams.itemSnapshotList.sumOf { it!!.duration } |     val totalDuration by remember { | ||||||
|  |         derivedStateOf { | ||||||
|  |             streams.itemSnapshotList.sumOf { it!!.duration } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|     val context = LocalContext.current |     val context = LocalContext.current | ||||||
|     val onClick = { stream: StreamInfoItem -> |     val onClick = { stream: StreamInfoItem -> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Isira Seneviratne
					Isira Seneviratne