diff --git a/lib/app/bloc/app_bloc.dart b/lib/app/bloc/app_bloc.dart index 44c77d2..dfb7f0c 100644 --- a/lib/app/bloc/app_bloc.dart +++ b/lib/app/bloc/app_bloc.dart @@ -461,20 +461,13 @@ class AppBloc extends Bloc { // --- POST-CHECK STATE RESOLUTION --- // If no critical status was found, we resolve the final state. - - // For an initial fetch, we transition from configFetching to the correct - // authenticated/anonymous state. - if (!event.isBackgroundCheck) { - final finalStatus = state.user!.appRole == AppUserRole.standardUser - ? AppStatus.authenticated - : AppStatus.anonymous; - emit(state.copyWith(remoteConfig: remoteConfig, status: finalStatus)); - } else { - // For a background check, the status is already correct (e.g., authenticated). - // We just need to update the remoteConfig in the state silently. - // The status does not need to change, preventing a disruptive UI rebuild. - emit(state.copyWith(remoteConfig: remoteConfig)); - } + // This logic applies to both initial fetches (transitioning from + // configFetching) and background checks (transitioning from a state + // like underMaintenance back to a running state). + final finalStatus = state.user!.appRole == AppUserRole.standardUser + ? AppStatus.authenticated + : AppStatus.anonymous; + emit(state.copyWith(remoteConfig: remoteConfig, status: finalStatus)); } on HttpException catch (e) { print( '[AppBloc] Failed to fetch AppConfig (HttpException) for user ${state.user?.id}: ${e.runtimeType} - ${e.message}', diff --git a/lib/app/services/app_status_service.dart b/lib/app/services/app_status_service.dart index 2a2bb7a..858c8e1 100644 --- a/lib/app/services/app_status_service.dart +++ b/lib/app/services/app_status_service.dart @@ -30,9 +30,9 @@ class AppStatusService with WidgetsBindingObserver { required BuildContext context, required Duration checkInterval, required AppEnvironment environment, - }) : _context = context, - _checkInterval = checkInterval, - _environment = environment { + }) : _context = context, + _checkInterval = checkInterval, + _environment = environment { // Immediately register this service as a lifecycle observer. WidgetsBinding.instance.addObserver(this); // Start the periodic checks. @@ -62,18 +62,16 @@ class AppStatusService with WidgetsBindingObserver { _timer = Timer.periodic(_checkInterval, (_) { // In demo mode, periodic checks are not needed as there's no backend. if (_environment == AppEnvironment.demo) { - print( - '[AppStatusService] Demo mode: Skipping periodic check.', - ); + print('[AppStatusService] Demo mode: Skipping periodic check.'); return; } print( '[AppStatusService] Periodic check triggered. Requesting AppConfig fetch.', ); // Add the event to the AppBloc to fetch the latest config. - _context - .read() - .add(const AppConfigFetchRequested(isBackgroundCheck: true)); + _context.read().add( + const AppConfigFetchRequested(isBackgroundCheck: true), + ); }); } @@ -92,9 +90,7 @@ class AppStatusService with WidgetsBindingObserver { // We are only interested in the 'resumed' state. if (state == AppLifecycleState.resumed) { - print( - '[AppStatusService] App resumed. Requesting AppConfig fetch.', - ); + print('[AppStatusService] App resumed. Requesting AppConfig fetch.'); // When the app comes to the foreground, immediately trigger a check. // This is crucial for catching maintenance mode that was enabled // while the app was in the background. diff --git a/lib/app/view/app.dart b/lib/app/view/app.dart index 029c37a..95f0a25 100644 --- a/lib/app/view/app.dart +++ b/lib/app/view/app.dart @@ -238,7 +238,10 @@ class _AppViewState extends State<_AppView> { fontFamily: null, ), themeMode: state.themeMode, - localizationsDelegates: AppLocalizations.localizationsDelegates, + localizationsDelegates: const [ + ...AppLocalizations.localizationsDelegates, + ...UiKitLocalizations.localizationsDelegates, + ], supportedLocales: AppLocalizations.supportedLocales, locale: state.locale, home: const MaintenancePage(), @@ -262,7 +265,10 @@ class _AppViewState extends State<_AppView> { fontFamily: null, ), themeMode: state.themeMode, - localizationsDelegates: AppLocalizations.localizationsDelegates, + localizationsDelegates: const [ + ...AppLocalizations.localizationsDelegates, + ...UiKitLocalizations.localizationsDelegates, + ], supportedLocales: AppLocalizations.supportedLocales, locale: state.locale, home: const UpdateRequiredPage(), @@ -289,7 +295,10 @@ class _AppViewState extends State<_AppView> { fontFamily: null, ), themeMode: state.themeMode, - localizationsDelegates: AppLocalizations.localizationsDelegates, + localizationsDelegates: const [ + ...AppLocalizations.localizationsDelegates, + ...UiKitLocalizations.localizationsDelegates, + ], supportedLocales: AppLocalizations.supportedLocales, locale: state.locale, home: const StatusPage(),