diff --git a/lib/fido/views/reset_dialog.dart b/lib/fido/views/reset_dialog.dart index a0b5dbd0..32e8d45a 100755 --- a/lib/fido/views/reset_dialog.dart +++ b/lib/fido/views/reset_dialog.dart @@ -44,7 +44,8 @@ class _ResetDialogState extends ConsumerState { Widget build(BuildContext context) { // If current device changes, we need to pop back to the main Page. ref.listen(currentDeviceProvider, (previous, next) { - Navigator.of(context).pop(); + // Prevent over-popping if reset causes currentDevice to change. + Navigator.of(context).popUntil((route) => route.isFirst); }); return ResponsiveDialog( @@ -79,23 +80,27 @@ class _ResetDialogState extends ConsumerState { _subscription = ref .read(fidoStateProvider(widget.node.path).notifier) .reset() - .listen( - (event) { - setState(() { - _interaction = event; - }); - }, - onDone: () { - _subscription = null; - Navigator.of(context).pop(); - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - content: Text('FIDO application reset'), - duration: Duration(seconds: 2), - ), - ); - }, - ); + .listen((event) { + setState(() { + _interaction = event; + }); + }, onDone: () { + _subscription = null; + Navigator.of(context).pop(); + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + content: Text('FIDO application reset'), + duration: Duration(seconds: 2), + ), + ); + }, onError: (_) { + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + content: Text('Error performing reset'), + duration: Duration(seconds: 2), + ), + ); + }); } : null, child: const Text('Reset'),