fix: avoid duplicate beat metadata fetching from api
This commit is contained in:
2
BUGS.md
2
BUGS.md
@@ -23,6 +23,8 @@
|
|||||||
|
|
||||||
## Nice-to
|
## Nice-to
|
||||||
|
|
||||||
|
- beat metadata is handled by the app, currently. The handling should move into "jukebox".
|
||||||
|
|
||||||
- add a test for /playlists/<playlist_id> but obfuscate the IDs and user id
|
- add a test for /playlists/<playlist_id> but obfuscate the IDs and user id
|
||||||
|
|
||||||
- TrackFileMatching, scoreAgainstLocalHints
|
- TrackFileMatching, scoreAgainstLocalHints
|
||||||
|
|||||||
@@ -91,17 +91,21 @@ fun AnnotationRoute(
|
|||||||
var playlistDisplayName by remember { mutableStateOf("playlist") }
|
var playlistDisplayName by remember { mutableStateOf("playlist") }
|
||||||
|
|
||||||
LaunchedEffect(playlistId) {
|
LaunchedEffect(playlistId) {
|
||||||
playlistDisplayName = viewModel.getPlaylistDisplayName(playlistId)
|
val name = viewModel.getPlaylistDisplayName(playlistId)
|
||||||
|
playlistDisplayName = name
|
||||||
|
viewModel.fetchBeatsMetadataForPlaylist(playlistId, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
LaunchedEffect(playback, playlistId, playlistDisplayName, annotationSessionFolder) {
|
LaunchedEffect(playback, playlistId, annotationSessionFolder) {
|
||||||
val service = playback ?: return@LaunchedEffect
|
val service = playback ?: return@LaunchedEffect
|
||||||
|
val name = viewModel.getPlaylistDisplayName(playlistId)
|
||||||
|
playlistDisplayName = name
|
||||||
service.trackBoundaryEvents.collect { event ->
|
service.trackBoundaryEvents.collect { event ->
|
||||||
val snapshot = beatTimesMs.toList()
|
val snapshot = beatTimesMs.toList()
|
||||||
beatTimesMs.clear()
|
beatTimesMs.clear()
|
||||||
viewModel.persistBeatAnnotation(
|
viewModel.persistBeatAnnotation(
|
||||||
playlistId,
|
playlistId,
|
||||||
playlistDisplayName,
|
name,
|
||||||
annotationSessionFolder,
|
annotationSessionFolder,
|
||||||
event,
|
event,
|
||||||
snapshot,
|
snapshot,
|
||||||
|
|||||||
@@ -212,11 +212,9 @@ fun NowPlayingRoute(
|
|||||||
}
|
}
|
||||||
|
|
||||||
LaunchedEffect(playlistId) {
|
LaunchedEffect(playlistId) {
|
||||||
playlistDisplayName = viewModel.getPlaylistDisplayName(playlistId)
|
val name = viewModel.getPlaylistDisplayName(playlistId)
|
||||||
}
|
playlistDisplayName = name
|
||||||
|
viewModel.fetchBeatsMetadataForPlaylist(playlistId, name)
|
||||||
LaunchedEffect(playlistId, playlistDisplayName) {
|
|
||||||
viewModel.fetchBeatsMetadataForPlaylist(playlistId, playlistDisplayName)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LaunchedEffect(playback) {
|
LaunchedEffect(playback) {
|
||||||
@@ -257,12 +255,14 @@ fun NowPlayingRoute(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LaunchedEffect(collectRunData, playback, playlistId, playlistDisplayName) {
|
LaunchedEffect(collectRunData, playback, playlistId) {
|
||||||
if (!collectRunData) return@LaunchedEffect
|
if (!collectRunData) return@LaunchedEffect
|
||||||
val service = playback ?: return@LaunchedEffect
|
val service = playback ?: return@LaunchedEffect
|
||||||
|
val name = viewModel.getPlaylistDisplayName(playlistId)
|
||||||
|
playlistDisplayName = name
|
||||||
service.trackBoundaryEvents.collect { event ->
|
service.trackBoundaryEvents.collect { event ->
|
||||||
val snapshot = collector.snapshotAndClear()
|
val snapshot = collector.snapshotAndClear()
|
||||||
viewModel.persistRunData(playlistId, playlistDisplayName, runSessionFolder, event, snapshot)
|
viewModel.persistRunData(playlistId, name, runSessionFolder, event, snapshot)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user