Fix routing to home after initial account creation

This commit is contained in:
Brandon Vandegrift 2025-04-03 14:27:56 -04:00
parent f4407e5284
commit e1f081105a
3 changed files with 27 additions and 16 deletions

View file

@ -63,10 +63,13 @@ class _NewAccountPageState extends WindowSetupState<NewAccountPage> {
return false;
}
final isFirstAccount =
AccountRepository.instance.getLocalAccounts().isEmpty;
final writableSuperIdentity = await AccountRepository.instance
.createWithNewSuperIdentity(accountSpec);
GoRouterHelper(context).pushReplacement('/new_account/recovery_key',
extra: [writableSuperIdentity, accountSpec.name]);
extra: [writableSuperIdentity, accountSpec.name, isFirstAccount]);
return true;
} finally {
@ -92,11 +95,15 @@ class _NewAccountPageState extends WindowSetupState<NewAccountPage> {
return StyledScaffold(
appBar: DefaultAppBar(
title: Text(translate('new_account_page.titlebar')),
leading: Navigator.canPop(context)
leading: GoRouterHelper(context).canPop()
? IconButton(
icon: const Icon(Icons.arrow_back),
onPressed: () {
Navigator.pop(context);
if (GoRouterHelper(context).canPop()) {
GoRouterHelper(context).pop();
} else {
GoRouterHelper(context).go('/');
}
},
)
: null,

View file

@ -25,15 +25,18 @@ class ShowRecoveryKeyPage extends StatefulWidget {
const ShowRecoveryKeyPage(
{required WritableSuperIdentity writableSuperIdentity,
required String name,
required bool isFirstAccount,
super.key})
: _writableSuperIdentity = writableSuperIdentity,
_name = name;
_name = name,
_isFirstAccount = isFirstAccount;
@override
State<ShowRecoveryKeyPage> createState() => _ShowRecoveryKeyPageState();
final WritableSuperIdentity _writableSuperIdentity;
final String _name;
final bool _isFirstAccount;
}
class _ShowRecoveryKeyPageState extends WindowSetupState<ShowRecoveryKeyPage> {
@ -248,9 +251,13 @@ class _ShowRecoveryKeyPageState extends WindowSetupState<ShowRecoveryKeyPage> {
child: ElevatedButton(
onPressed: () {
if (context.mounted) {
Navigator.canPop(context)
? GoRouterHelper(context).pop()
: GoRouterHelper(context).go('/');
if (widget._isFirstAccount) {
GoRouterHelper(context).go('/');
} else {
GoRouterHelper(context).canPop()
? GoRouterHelper(context).pop()
: GoRouterHelper(context).go('/');
}
}
},
child: Text(translate('button.finish')).paddingAll(8))