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

View File

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

View File

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

View File

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