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:
2026-07-06 19:41:51 +02:00
parent 9f7427e72f
commit e967007bdc

View File

@@ -86,13 +86,16 @@ fun ImportScreen(
} }
// Hoisted target calendar so the always-visible top-bar Import action can // 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 // read it without the user scrolling to a bottom button. Defaults to the
// first calendar when the "many" list first arrives (keyed on it), then // first *local* calendar the first row the picker shows ("Your calendars"
// holds the user's pick. // 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 val many = state as? ImportUiState.Many
var selected by rememberSaveable(many?.calendars?.firstOrNull()?.id) { val defaultTarget = many?.calendars?.let { cals ->
mutableStateOf(many?.calendars?.firstOrNull()?.id) (cals.firstOrNull { it.isLocal } ?: cals.firstOrNull())?.id
} }
var selected by rememberSaveable(defaultTarget) { mutableStateOf(defaultTarget) }
Scaffold( Scaffold(
modifier = Modifier modifier = Modifier