mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-31 15:59:26 +00:00
Merge pull request #764 from cypherstack/null-wallet
Do not trap user in "restore failed" dialog if serverside issues lead to failure
This commit is contained in:
commit
d6710166f9
2 changed files with 23 additions and 8 deletions
|
@ -13,6 +13,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|||
import 'package:stackwallet/providers/global/secure_store_provider.dart';
|
||||
import 'package:stackwallet/providers/providers.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/logger.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart';
|
||||
import 'package:stackwallet/widgets/stack_dialog.dart';
|
||||
|
@ -65,13 +66,21 @@ class _RestoreFailedDialogState extends ConsumerState<RestoreFailedDialog> {
|
|||
style: STextStyles.itemSubtitle12(context),
|
||||
),
|
||||
onPressed: () async {
|
||||
await ref.read(pWallets).deleteWallet(
|
||||
ref.read(pWalletInfo(walletId)),
|
||||
ref.read(secureStoreProvider),
|
||||
);
|
||||
|
||||
if (mounted) {
|
||||
Navigator.of(context).pop();
|
||||
try {
|
||||
await ref.read(pWallets).deleteWallet(
|
||||
ref.read(pWalletInfo(walletId)),
|
||||
ref.read(secureStoreProvider),
|
||||
);
|
||||
} catch (e, s) {
|
||||
Logging.instance.log(
|
||||
"Error while getting wallet info in restore failed dialog\n"
|
||||
"Error: $e\nStack trace: $s",
|
||||
level: LogLevel.Error,
|
||||
);
|
||||
} finally {
|
||||
if (mounted) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
|
|
|
@ -42,7 +42,13 @@ class Wallets {
|
|||
|
||||
final Map<String, Wallet> _wallets = {};
|
||||
|
||||
Wallet getWallet(String walletId) => _wallets[walletId]!;
|
||||
Wallet getWallet(String walletId) {
|
||||
if (_wallets[walletId] != null) {
|
||||
return _wallets[walletId]!;
|
||||
} else {
|
||||
throw Exception("Wallet with id $walletId not found");
|
||||
}
|
||||
}
|
||||
|
||||
void addWallet(Wallet wallet) {
|
||||
if (_wallets[wallet.walletId] != null) {
|
||||
|
|
Loading…
Reference in a new issue