Preserve navigation focus when Anime availability changes
Some checks failed
review/code-gpt Anime removal leaves active root invalid; Back pops a singleton stack (B1).

This commit is contained in:
justinzeus 2026-11-06 12:33:10 +01:00
parent 53b8358317
commit 9e15dbee8c
3 changed files with 12 additions and 2 deletions

View file

@ -50,14 +50,17 @@ class ShellState(
var people by mutableStateOf(people)
private set
/** Refresh household labels without discarding this person's navigation memory. */
/** Refresh household data without losing valid nav focus or this person's view memory. */
fun updatePeople(value: List<ShellPerson>) {
val focusedTab = tabs.getOrNull(navIndex)
val avatarFocused = navIndex == tabs.size
val selected = value.firstOrNull { it.jellyfinUserId != null && it.jellyfinUserId == person.jellyfinUserId }
?: value.firstOrNull { it.key == person.key }
people = value
if (selected != null) person = selected
pickerIndex = people.indexOf(person).coerceAtLeast(0)
preparePersonMemory()
navIndex = if (avatarFocused) tabs.size else tabs.indexOf(focusedTab).takeIf { it >= 0 } ?: currentTab
}
var person by mutableStateOf(people.firstOrNull { it.key == initialPerson } ?: people.first())
private set