Skip to content

Commit f69ab08

Browse files
committed
feat(router): add demo environment workaround for initial auth state
- Implement a workaround for the demo environment to handle initial auth state - Redirect to authentication page if app status is initial in demo mode - Avoid black screen by forcing authentication page in demo flow
1 parent 4c0233e commit f69ab08

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

lib/router/router.dart

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,24 @@ GoRouter createRouter({
8989
' AppStatus: $appStatus',
9090
);
9191

92-
// --- Define Key Paths ---
9392
const rootPath = '/';
9493
const authenticationPath = Routes.authentication;
9594
const feedPath = Routes.feed;
9695
final isGoingToAuth = currentLocation.startsWith(authenticationPath);
9796

97+
// --- Workaround for Demo Environment ---
98+
// In the demo environment, the initial auth state from the in-memory
99+
// client might not be emitted before the first redirect check. If the app
100+
// is still in the `initial` state, we explicitly redirect to the
101+
// authentication page to begin the demo flow, avoiding the black screen.
102+
if (appStatus == AppStatus.initial &&
103+
environment == local_config.AppEnvironment.demo) {
104+
print(
105+
' Redirect (Workaround): In demo mode with initial status. Forcing to authentication.',
106+
);
107+
return authenticationPath;
108+
}
109+
98110
// With the new App startup architecture, the router is only active when
99111
// the app is in a stable, running state. The `redirect` function's
100112
// only responsibility is to handle auth-based route protection.

0 commit comments

Comments
 (0)