fixed guardian login edge cases and misleading placeholders on failed loads
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user