From 89376cef8615fd30673ed550465be5f6c66d213c Mon Sep 17 00:00:00 2001 From: austinried <4966622+austinried@users.noreply.github.com> Date: Thu, 24 Sep 2026 14:07:57 +0000 Subject: [PATCH] rescan the queue scroll to the current track on every open --- .../main/kotlin/com/subtracks/ui/playback/QueueScreen.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/subtracks/ui/playback/QueueScreen.kt b/app/src/main/kotlin/com/subtracks/ui/playback/QueueScreen.kt index 41b46f82..c37c9ef4 100644 --- a/app/src/main/kotlin/com/subtracks/ui/playback/QueueScreen.kt +++ b/app/src/main/kotlin/com/subtracks/ui/playback/QueueScreen.kt @@ -87,6 +87,9 @@ class QueueViewModel( var initialIndex by mutableStateOf(0) private set + var generation by mutableStateOf(0) + private set + private var nextId = 0L private val mutex = Mutex() private var size = 0L @@ -116,6 +119,7 @@ class QueueViewModel( initialIndex = (cursor - first).toInt().coerceAtLeast(0) } ready = true + generation++ } } } @@ -260,6 +264,7 @@ fun QueueRoute( rows = viewModel.rows, ready = viewModel.ready, initialIndex = viewModel.initialIndex, + generation = viewModel.generation, currentSongId = playback.item?.id, coverArt = sourceRepository::coverArt, onBack = onBack, @@ -291,6 +296,7 @@ fun QueueScreen( onUndo: () -> Unit, modifier: Modifier = Modifier, initialIndex: Int = 0, + generation: Int = 0, ) { val listState = rememberLazyListState() val fill = rememberViewportFill(listState) @@ -304,7 +310,7 @@ fun QueueScreen( onReorder(from.index, to.index) } - LaunchedEffect(listState, ready) { + LaunchedEffect(listState, ready, generation) { if (!ready) return@LaunchedEffect if (initialIndex > 0) listState.scrollToItem(initialIndex) snapshotFlow {