mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2025-07-24 15:05:22 -04:00
Fix routing to home after initial account creation
This commit is contained in:
parent
f4407e5284
commit
e1f081105a
3 changed files with 27 additions and 16 deletions
|
@ -96,7 +96,8 @@ class RouterCubit extends Cubit<RouterState> {
|
|||
if (extra == null ||
|
||||
extra is! List<Object> ||
|
||||
extra[0] is! WritableSuperIdentity ||
|
||||
extra[1] is! String) {
|
||||
extra[1] is! String ||
|
||||
extra[2] is! bool) {
|
||||
return '/';
|
||||
}
|
||||
return null;
|
||||
|
@ -107,7 +108,8 @@ class RouterCubit extends Cubit<RouterState> {
|
|||
return ShowRecoveryKeyPage(
|
||||
writableSuperIdentity:
|
||||
extra[0] as WritableSuperIdentity,
|
||||
name: extra[1] as String);
|
||||
name: extra[1] as String,
|
||||
isFirstAccount: extra[2] as bool);
|
||||
}),
|
||||
]),
|
||||
GoRoute(
|
||||
|
@ -123,14 +125,8 @@ class RouterCubit extends Cubit<RouterState> {
|
|||
|
||||
/// Redirects when our state changes
|
||||
String? redirect(BuildContext context, GoRouterState goRouterState) {
|
||||
// No matter where we are, if there's not
|
||||
|
||||
switch (goRouterState.matchedLocation) {
|
||||
case '/':
|
||||
if (!state.hasAnyAccount) {
|
||||
return '/new_account';
|
||||
}
|
||||
return null;
|
||||
// We can go to any of these routes without an account.
|
||||
case '/new_account':
|
||||
return null;
|
||||
case '/new_account/recovery_key':
|
||||
|
@ -139,6 +135,7 @@ class RouterCubit extends Cubit<RouterState> {
|
|||
return null;
|
||||
case '/developer':
|
||||
return null;
|
||||
// Otherwise, if there's no account, we need to go to the new account page.
|
||||
default:
|
||||
return state.hasAnyAccount ? null : '/new_account';
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue