fix(#166): review - group editor waits for the calendars before seeding members

This commit is contained in:
makiolaj committed 2026-12-02 18:09:26 +01:00
1 parent f7329e45e3
commit 9560f230b8
2 files changed
+11 -1

No files matched your search

@@ -145,6 +145,7 @@ fun CalendarsScreen(
viewModel: CalendarsViewModel = hiltViewModel(),
) {
val calendars by viewModel.calendars.collectAsStateWithLifecycle()
val calendarsLoaded by viewModel.calendarsLoaded.collectAsStateWithLifecycle()
val deleteLockedIds by viewModel.deleteLockedCalendarIds.collectAsStateWithLifecycle()
val error by viewModel.error.collectAsStateWithLifecycle()
val syncAccessDismissed by viewModel.syncAccessDismissed.collectAsStateWithLifecycle()
@@ -216,7 +217,8 @@ fun CalendarsScreen(
val editing = groups?.firstOrNull { it.id == id }
if (groups != null && id != NEW_GROUP_ID && editing == null) {
LaunchedEffect(id) { groupEditorId = null }
} else if (groups != null) {
} else if (groups != null && calendarsLoaded) {
// Seeded once per open, so it waits for the calendars its members resolve against.
CalendarGroupEditor(
sessionKey = editorSession,
isNew = editing == null,
@@ -69,6 +69,14 @@ class CalendarsViewModel @Inject constructor(
initialValue = emptyList(),
)
/** Whether [calendars] holds a real read rather than its empty start or a failed read's empty list. */
val calendarsLoaded: StateFlow<Boolean> =
repository.calendars()
.map { true }
.catch { emit(false) }
.flowOn(io)
.stateWhileSubscribed(scope = viewModelScope, initialValue = false)
/**
* Accounts the drawer was told not to ask sync-request access for (#240),
* limited to those still behind a visible calendar and still unreachable.