Skip to content

Commit d902974

Browse files
committed
refactor(app): improve user data loading logic and state handling
- Update loading condition to check for `loadingUserData` status - Add comments to explain the loading state logic - Wrap LoadingStateWidget in a Builder to potentially improve widget tree structure
1 parent cad13fa commit d902974

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

lib/app/view/app.dart

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -413,10 +413,12 @@ class _AppViewState extends State<_AppView> {
413413
}
414414

415415
// --- Loading User Data State ---
416-
// If the app is not in a critical status but user settings or preferences
417-
// are still null, display a loading screen. This ensures the main UI
418-
// is only built when all necessary user-specific data is available.
419-
if (state.settings == null || state.userContentPreferences == null) {
416+
// --- Loading User Data State ---
417+
// Display a loading screen ONLY if the app is actively trying to load
418+
// user-specific data (settings or preferences) for an authenticated/anonymous user.
419+
// If the status is unauthenticated, it means there's no user data to load,
420+
// and the app should proceed to the router to show the authentication page.
421+
if (state.status == AppLifeCycleStatus.loadingUserData) {
420422
return MaterialApp(
421423
debugShowCheckedModeBanner: false,
422424
theme: lightTheme(
@@ -438,12 +440,16 @@ class _AppViewState extends State<_AppView> {
438440
],
439441
supportedLocales: AppLocalizations.supportedLocales,
440442
locale: state.locale,
441-
home: LoadingStateWidget(
442-
icon: Icons.sync,
443-
headline: AppLocalizations.of(context).settingsLoadingHeadline,
444-
subheadline: AppLocalizations.of(
445-
context,
446-
).settingsLoadingSubheadline,
443+
home: Builder(
444+
builder: (context) {
445+
return LoadingStateWidget(
446+
icon: Icons.sync,
447+
headline: AppLocalizations.of(context).settingsLoadingHeadline,
448+
subheadline: AppLocalizations.of(
449+
context,
450+
).settingsLoadingSubheadline,
451+
);
452+
},
447453
),
448454
);
449455
}

0 commit comments

Comments
 (0)