fix: default import target to the first local calendar
The pre-selected target was calendars.first() (raw provider order), which could land on a synced calendar mid-list while the picker shows local calendars first. Default to the first local calendar so the checkmark lines up with the top row; fall back to the first calendar when none are local. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -86,13 +86,16 @@ fun ImportScreen(
|
||||
}
|
||||
|
||||
// Hoisted target calendar so the always-visible top-bar Import action can
|
||||
// read it without the user scrolling to a bottom button. Re-defaults to the
|
||||
// first calendar when the "many" list first arrives (keyed on it), then
|
||||
// holds the user's pick.
|
||||
// read it without the user scrolling to a bottom button. Defaults to the
|
||||
// first *local* calendar — the first row the picker shows ("Your calendars"
|
||||
// group leads) — so the pre-selection lines up with the top of the list;
|
||||
// falls back to the first calendar if there are no local ones. Re-defaults
|
||||
// when the "many" list first arrives (keyed on it), then holds the pick.
|
||||
val many = state as? ImportUiState.Many
|
||||
var selected by rememberSaveable(many?.calendars?.firstOrNull()?.id) {
|
||||
mutableStateOf(many?.calendars?.firstOrNull()?.id)
|
||||
val defaultTarget = many?.calendars?.let { cals ->
|
||||
(cals.firstOrNull { it.isLocal } ?: cals.firstOrNull())?.id
|
||||
}
|
||||
var selected by rememberSaveable(defaultTarget) { mutableStateOf(defaultTarget) }
|
||||
|
||||
Scaffold(
|
||||
modifier = Modifier
|
||||
|
||||
Reference in New Issue
Block a user