Keep Home responsive and resolve authorized request recipients
Some checks failed
review/code-claude Block: token sent to image hosts via Coil auth client; failed audiences read hides Jellyfin libraries
Some checks failed
review/code-claude Block: token sent to image hosts via Coil auth client; failed audiences read hides Jellyfin libraries
This commit is contained in:
parent
78322f588a
commit
09f1d72f30
13 changed files with 120 additions and 29 deletions
|
|
@ -19,12 +19,22 @@ class DiscoverState(
|
|||
private val onPush: (String) -> Unit = {},
|
||||
private val onPop: () -> Unit = {},
|
||||
private val serviceLanes: (DiscoverService, String) -> List<DiscoverLane> = { _, _ -> emptyList() },
|
||||
private val requesters: List<ShellPerson> = shell.people,
|
||||
requesters: List<ShellPerson> = shell.people,
|
||||
private val onMore: (suspend (String) -> List<DiscoverLane>?)? = null,
|
||||
private val nowMillis: () -> Long = System::currentTimeMillis,
|
||||
) : ShellContentFocus {
|
||||
var snapshot by mutableStateOf(initial)
|
||||
private set
|
||||
private var requesters = requesters
|
||||
|
||||
fun updateRequesters(people: List<ShellPerson>) {
|
||||
if (requesters == people) return
|
||||
requesters = people
|
||||
requestSheets.values.forEach { it.updatePeople(people) }
|
||||
(overlay as? DiscoverOverlayState.Request)?.state?.let { current ->
|
||||
if (requestSheets.values.none { it === current }) current.updatePeople(people)
|
||||
}
|
||||
}
|
||||
private var savedTime = initial.savedAt ?: formatSavedTime()
|
||||
private var serviceFilter by mutableStateOf("movie")
|
||||
var filter: String
|
||||
|
|
|
|||
|
|
@ -20,10 +20,11 @@ class RequestSheetState(
|
|||
other: Boolean,
|
||||
initialPhase: RequestPhase = RequestPhase.Choose,
|
||||
) {
|
||||
val people = listOf(viewer) + people.filter { it.key != viewer.key }
|
||||
var people by mutableStateOf(listOf(viewer) + people.filter { it.key != viewer.key })
|
||||
private set
|
||||
val held = viewer.key in title.heldBy
|
||||
val blocked = title.type == "tv" && !held && title.seasons.isNullOrEmpty()
|
||||
val buttonIndex = this.people.size
|
||||
val buttonIndex: Int get() = people.size
|
||||
var selected by mutableStateOf(if (other || held) this.people.indexOfFirst { it.key != viewer.key && it.key !in title.heldBy }.coerceAtLeast(0) else 0)
|
||||
var phase by mutableStateOf(initialPhase)
|
||||
var focus by mutableStateOf(if (initialPhase != RequestPhase.Choose || blocked || !other) buttonIndex else selected)
|
||||
|
|
@ -36,6 +37,15 @@ class RequestSheetState(
|
|||
else -> "Request for ${selectedPerson.name}"
|
||||
}
|
||||
|
||||
fun updatePeople(value: List<ShellPerson>) {
|
||||
val selectedKey = selectedPerson.key
|
||||
val focusedKey = people.getOrNull(focus)?.key
|
||||
val footerOffset = focus - buttonIndex
|
||||
people = listOf(viewer) + value.filter { it.key != viewer.key }
|
||||
selected = people.indexOfFirst { it.key == selectedKey }.coerceAtLeast(0)
|
||||
focus = if (footerOffset >= 0) buttonIndex + footerOffset else people.indexOfFirst { it.key == focusedKey }.coerceAtLeast(0)
|
||||
}
|
||||
|
||||
fun key(key: ShellKey, send: (RequestSheetState, Boolean) -> Unit, close: () -> Unit, retryRecipients: () -> Unit) {
|
||||
if (key == ShellKey.Back) { close(); return }
|
||||
when (phase) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue