Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions lib/db/isar/main_db.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
*
*/

import 'dart:io';

import 'package:decimal/decimal.dart';
import 'package:isar_community/isar.dart';
import 'package:tuple/tuple.dart';
Expand Down Expand Up @@ -76,7 +78,7 @@ class MainDB {
// inspector: kDebugMode,
inspector: false,
name: "wallet_data",
maxSizeMiB: 512,
maxSizeMiB: Platform.isWindows ? 1024 : 512,
);
return true;
}
Expand Down Expand Up @@ -445,18 +447,16 @@ class MainDB {

//
Future<void> deleteWalletBlockchainData(String walletId) async {
final transactionCount = await getTransactions(walletId).count();
final transactionCountV2 = await isar.transactionV2s
.where()
.walletIdEqualTo(walletId)
.count();
final addressCount = await getAddresses(walletId).count();
final utxoCount = await getUTXOs(walletId).count();
// final lelantusCoinCount =
// await isar.lelantusCoins.where().walletIdEqualTo(walletId).count();

await isar.writeTxn(() async {
const paginateLimit = 50;
final transactionCount = await getTransactions(walletId).count();
final transactionCountV2 = await isar.transactionV2s
.where()
.walletIdEqualTo(walletId)
.count();
final addressCount = await getAddresses(walletId).count();
final utxoCount = await getUTXOs(walletId).count();

const paginateLimit = 100;

// transactions
for (int i = 0; i < transactionCount; i += paginateLimit) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,11 @@ class _TransactionsV2ListState extends ConsumerState<TransactionsV2List> {

_subscription = _query.watch().listen((event) {
WidgetsBinding.instance.addPostFrameCallback((_) {
setState(() {
_transactions = event;
});
if (mounted) {
setState(() {
_transactions = event;
});
}
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

import '../../../../notifications/show_flush_bar.dart';
import '../../../../pages/add_wallet_views/new_wallet_recovery_phrase_view/sub_widgets/mnemonic_table.dart';
import '../../../../providers/global/secure_store_provider.dart';
Expand All @@ -21,6 +22,7 @@ import '../../../../route_generator.dart';
import '../../../../themes/stack_colors.dart';
import '../../../../utilities/assets.dart';
import '../../../../utilities/clipboard_interface.dart';
import '../../../../utilities/logger.dart';
import '../../../../utilities/text_styles.dart';
import '../../../../wallets/isar/providers/wallet_info_provider.dart';
import '../../../../widgets/desktop/desktop_dialog.dart';
Expand Down Expand Up @@ -52,6 +54,11 @@ class _DeleteWalletKeysPopup extends ConsumerState<DeleteWalletKeysPopup> {
late final List<String> _words;
late final ClipboardInterface _clipboardInterface;

static const _recoveryPhraseInfo =
"Please write down your recovery phrase in the correct order and save it "
"to keep your funds secure. "
"You will be shown your recovery phrase on the next screen.";

@override
void initState() {
_walletId = widget.walletId;
Expand All @@ -72,61 +79,45 @@ class _DeleteWalletKeysPopup extends ConsumerState<DeleteWalletKeysPopup> {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Padding(
padding: const EdgeInsets.only(
left: 32,
),
padding: const EdgeInsets.only(left: 32),
child: Text(
"Wallet keys",
style: STextStyles.desktopH3(context),
),
),
DesktopDialogCloseButton(
onPressedOverride: () {
Navigator.of(
context,
rootNavigator: true,
).pop();
Navigator.of(context, rootNavigator: true).pop();
},
),
],
),
const SizedBox(
height: 28,
),
const SizedBox(height: 28),
Text(
"Recovery phrase",
style: STextStyles.desktopTextMedium(context),
),
const SizedBox(
height: 8,
),
const SizedBox(height: 8),
Center(
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 32,
),
padding: const EdgeInsets.symmetric(horizontal: 32),
child: Text(
"Please write down your recovery phrase in the correct order and "
"save it to keep your funds secure. You will be shown your recovery phrase on the next screen.",
_recoveryPhraseInfo,
style: STextStyles.desktopTextExtraExtraSmall(context),
textAlign: TextAlign.center,
),
),
),
const SizedBox(
height: 24,
),
const SizedBox(height: 24),
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 32,
),
padding: const EdgeInsets.symmetric(horizontal: 32),
child: RawMaterialButton(
hoverColor: Colors.transparent,
onPressed: () async {
await _clipboardInterface.setData(
ClipboardData(text: _words.join(" ")),
);
if (mounted) {
if (context.mounted) {
unawaited(
showFloatingFlushBar(
type: FlushBarType.info,
Expand All @@ -140,19 +131,15 @@ class _DeleteWalletKeysPopup extends ConsumerState<DeleteWalletKeysPopup> {
child: MnemonicTable(
words: widget.words,
isDesktop: true,
itemBorderColor: Theme.of(context)
.extension<StackColors>()!
.buttonBackSecondary,
itemBorderColor: Theme.of(
context,
).extension<StackColors>()!.buttonBackSecondary,
),
),
),
const SizedBox(
height: 24,
),
const SizedBox(height: 24),
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 32,
),
padding: const EdgeInsets.symmetric(horizontal: 32),
child: Row(
children: [
Expanded(
Expand All @@ -162,9 +149,7 @@ class _DeleteWalletKeysPopup extends ConsumerState<DeleteWalletKeysPopup> {
await Navigator.of(context).push(
RouteGenerator.getRoute(
builder: (context) {
return ConfirmDelete(
walletId: _walletId,
);
return ConfirmDelete(walletId: _walletId);
},
settings: const RouteSettings(
name: "/desktopConfirmDelete",
Expand All @@ -177,20 +162,15 @@ class _DeleteWalletKeysPopup extends ConsumerState<DeleteWalletKeysPopup> {
],
),
),
const SizedBox(
height: 32,
),
const SizedBox(height: 32),
],
),
);
}
}

class ConfirmDelete extends ConsumerStatefulWidget {
const ConfirmDelete({
super.key,
required this.walletId,
});
const ConfirmDelete({super.key, required this.walletId});

final String walletId;

Expand All @@ -207,9 +187,7 @@ class _ConfirmDeleteState extends ConsumerState<ConfirmDelete> {
children: [
const Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
DesktopDialogCloseButton(),
],
children: [DesktopDialogCloseButton()],
),
Column(
crossAxisAlignment: CrossAxisAlignment.center,
Expand Down Expand Up @@ -238,12 +216,22 @@ class _ConfirmDeleteState extends ConsumerState<ConfirmDelete> {
buttonHeight: ButtonHeight.xl,
label: "Continue",
onPressed: () async {
await ref.read(pWallets).deleteWallet(
ref.read(pWalletInfo(widget.walletId)),
ref.read(secureStoreProvider),
);
try {
await ref
.read(pWallets)
.deleteWallet(
ref.read(pWalletInfo(widget.walletId)),
ref.read(secureStoreProvider),
);
} catch (e, s) {
Logging.instance.f(
"Wallet deletion errors",
error: e,
stackTrace: s,
);
}

if (mounted) {
if (context.mounted) {
Navigator.of(context, rootNavigator: true).pop(true);
}
},
Expand Down
Loading
Loading