mirror of
https://github.com/austinried/subtracks.git
synced 2026-11-11 15:29:15 +01:00
rescan the queue scroll to the current track on every open
This commit is contained in:
@@ -87,6 +87,9 @@ class QueueViewModel(
|
|||||||
var initialIndex by mutableStateOf(0)
|
var initialIndex by mutableStateOf(0)
|
||||||
private set
|
private set
|
||||||
|
|
||||||
|
var generation by mutableStateOf(0)
|
||||||
|
private set
|
||||||
|
|
||||||
private var nextId = 0L
|
private var nextId = 0L
|
||||||
private val mutex = Mutex()
|
private val mutex = Mutex()
|
||||||
private var size = 0L
|
private var size = 0L
|
||||||
@@ -116,6 +119,7 @@ class QueueViewModel(
|
|||||||
initialIndex = (cursor - first).toInt().coerceAtLeast(0)
|
initialIndex = (cursor - first).toInt().coerceAtLeast(0)
|
||||||
}
|
}
|
||||||
ready = true
|
ready = true
|
||||||
|
generation++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -260,6 +264,7 @@ fun QueueRoute(
|
|||||||
rows = viewModel.rows,
|
rows = viewModel.rows,
|
||||||
ready = viewModel.ready,
|
ready = viewModel.ready,
|
||||||
initialIndex = viewModel.initialIndex,
|
initialIndex = viewModel.initialIndex,
|
||||||
|
generation = viewModel.generation,
|
||||||
currentSongId = playback.item?.id,
|
currentSongId = playback.item?.id,
|
||||||
coverArt = sourceRepository::coverArt,
|
coverArt = sourceRepository::coverArt,
|
||||||
onBack = onBack,
|
onBack = onBack,
|
||||||
@@ -291,6 +296,7 @@ fun QueueScreen(
|
|||||||
onUndo: () -> Unit,
|
onUndo: () -> Unit,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
initialIndex: Int = 0,
|
initialIndex: Int = 0,
|
||||||
|
generation: Int = 0,
|
||||||
) {
|
) {
|
||||||
val listState = rememberLazyListState()
|
val listState = rememberLazyListState()
|
||||||
val fill = rememberViewportFill(listState)
|
val fill = rememberViewportFill(listState)
|
||||||
@@ -304,7 +310,7 @@ fun QueueScreen(
|
|||||||
onReorder(from.index, to.index)
|
onReorder(from.index, to.index)
|
||||||
}
|
}
|
||||||
|
|
||||||
LaunchedEffect(listState, ready) {
|
LaunchedEffect(listState, ready, generation) {
|
||||||
if (!ready) return@LaunchedEffect
|
if (!ready) return@LaunchedEffect
|
||||||
if (initialIndex > 0) listState.scrollToItem(initialIndex)
|
if (initialIndex > 0) listState.scrollToItem(initialIndex)
|
||||||
snapshotFlow {
|
snapshotFlow {
|
||||||
|
|||||||
Reference in New Issue
Block a user