fixed guardian login edge cases and misleading placeholders on failed loads

This commit is contained in:
2026-09-20 19:03:45 +02:00
parent 2423c1a75e
commit 630497abdd
23 changed files with 299 additions and 72 deletions
@@ -25,8 +25,9 @@ class CapabilitiesCubit extends HydratedCubit<CapabilitiesState> {
/// Refreshes capabilities from the server. On any failure (endpoint not yet
/// live, network error, 4xx) the previously hydrated flags are kept but the
/// state is marked `loaded` — a failed fetch never silently grants a
/// capability, and an offline launch keeps whatever was cached.
/// state is marked `loaded` and `loadFailed` — a failed fetch never silently
/// grants a capability, an offline launch keeps whatever was cached, and the
/// UI can offer a retry instead of claiming a guardian has no children.
Future<void> load() async {
if (DemoMode.active) {
emit(
@@ -51,11 +52,11 @@ class CapabilitiesCubit extends HydratedCubit<CapabilitiesState> {
);
} catch (e) {
log('Failed to load capabilities: $e');
emit(state.copyWith(loaded: true));
emit(state.copyWith(loaded: true, loadFailed: true));
}
}
Future<void> reset() async => emit(const CapabilitiesState());
void reset() => emit(const CapabilitiesState());
@override
CapabilitiesState fromJson(Map<String, dynamic> json) {