Fix recovery flow

pull/90/head
Inex Code 2022-05-31 17:30:35 +03:00
parent 8ec3b8c3e3
commit 7810c2a279
4 changed files with 15 additions and 6 deletions

View File

@ -461,6 +461,7 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
await repository.saveHasFinalChecked(true); await repository.saveHasFinalChecked(true);
await repository.saveIsRecoveringServer(false); await repository.saveIsRecoveringServer(false);
final mainUser = await repository.getMainUser(); final mainUser = await repository.getMainUser();
await repository.saveRootUser(mainUser);
final updatedState = (state as ServerInstallationRecovery).copyWith( final updatedState = (state as ServerInstallationRecovery).copyWith(
backblazeCredential: backblazeCredential, backblazeCredential: backblazeCredential,
rootUser: mainUser, rootUser: mainUser,
@ -502,7 +503,7 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
if (state.serverDetails != null) { if (state.serverDetails != null) {
await repository.deleteServer(state.serverDomain!); await repository.deleteServer(state.serverDomain!);
} }
await repository.deleteRecords(); await repository.deleteServerRelatedRecords();
emit(ServerInstallationNotFinished( emit(ServerInstallationNotFinished(
hetznerKey: state.hetznerKey, hetznerKey: state.hetznerKey,
serverDomain: state.serverDomain, serverDomain: state.serverDomain,

View File

@ -628,7 +628,7 @@ class ServerInstallationRepository {
await cloudFlare.removeSimilarRecords(cloudFlareDomain: serverDomain); await cloudFlare.removeSimilarRecords(cloudFlareDomain: serverDomain);
} }
Future<void> deleteRecords() async { Future<void> deleteServerRelatedRecords() async {
await box.deleteAll([ await box.deleteAll([
BNames.serverDetails, BNames.serverDetails,
BNames.isServerStarted, BNames.isServerStarted,
@ -636,6 +636,7 @@ class ServerInstallationRepository {
BNames.isServerResetedSecondTime, BNames.isServerResetedSecondTime,
BNames.hasFinalChecked, BNames.hasFinalChecked,
BNames.isLoading, BNames.isLoading,
BNames.isRecoveringServer,
]); ]);
getIt<ApiConfigModel>().init(); getIt<ApiConfigModel>().init();
} }

View File

@ -24,7 +24,7 @@ class RecoveryKey extends StatefulWidget {
class _RecoveryKeyState extends State<RecoveryKey> { class _RecoveryKeyState extends State<RecoveryKey> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
var keyStatus = context.watch<RecoveryKeyCubit>().state; final keyStatus = context.watch<RecoveryKeyCubit>().state;
final List<Widget> widgets; final List<Widget> widgets;
final String? subtitle = final String? subtitle =

View File

@ -60,9 +60,16 @@ class RecoveryRouting extends StatelessWidget {
} }
} }
return AnimatedSwitcher( return BlocListener<ServerInstallationCubit, ServerInstallationState>(
duration: const Duration(milliseconds: 300), listener: (context, state) {
child: currentPage, if (state is ServerInstallationFinished) {
Navigator.of(context).popUntil((route) => route.isFirst);
}
},
child: AnimatedSwitcher(
duration: const Duration(milliseconds: 300),
child: currentPage,
),
); );
} }
} }