mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-03-21 06:38:52 +00:00
add delete address labels and tx notes functionality (isar notes unimplemented atm)
This commit is contained in:
parent
eb42493e4d
commit
74ca8e1e07
2 changed files with 44 additions and 10 deletions
|
@ -257,30 +257,62 @@ class MainDB {
|
||||||
|
|
||||||
// transactions
|
// transactions
|
||||||
for (int i = 0; i < transactionCount; i += paginateLimit) {
|
for (int i = 0; i < transactionCount; i += paginateLimit) {
|
||||||
final txns = await getTransactions(walletId)
|
final txnIds = await getTransactions(walletId)
|
||||||
.offset(i)
|
.offset(i)
|
||||||
.limit(paginateLimit)
|
.limit(paginateLimit)
|
||||||
|
.idProperty()
|
||||||
.findAll();
|
.findAll();
|
||||||
await isar.transactions
|
await isar.transactions.deleteAll(txnIds);
|
||||||
.deleteAll(txns.map((e) => e.id).toList(growable: false));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// addresses
|
// addresses
|
||||||
for (int i = 0; i < addressCount; i += paginateLimit) {
|
for (int i = 0; i < addressCount; i += paginateLimit) {
|
||||||
final addresses = await getAddresses(walletId)
|
final addressIds = await getAddresses(walletId)
|
||||||
.offset(i)
|
.offset(i)
|
||||||
.limit(paginateLimit)
|
.limit(paginateLimit)
|
||||||
|
.idProperty()
|
||||||
.findAll();
|
.findAll();
|
||||||
await isar.addresses
|
await isar.addresses.deleteAll(addressIds);
|
||||||
.deleteAll(addresses.map((e) => e.id).toList(growable: false));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// utxos
|
// utxos
|
||||||
for (int i = 0; i < utxoCount; i += paginateLimit) {
|
for (int i = 0; i < utxoCount; i += paginateLimit) {
|
||||||
final utxos =
|
final utxoIds = await getUTXOs(walletId)
|
||||||
await getUTXOs(walletId).offset(i).limit(paginateLimit).findAll();
|
.offset(i)
|
||||||
await isar.utxos
|
.limit(paginateLimit)
|
||||||
.deleteAll(utxos.map((e) => e.id).toList(growable: false));
|
.idProperty()
|
||||||
|
.findAll();
|
||||||
|
await isar.utxos.deleteAll(utxoIds);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> deleteAddressLabels(String walletId) async {
|
||||||
|
final addressLabelCount = await getAddressLabels(walletId).count();
|
||||||
|
await isar.writeTxn(() async {
|
||||||
|
const paginateLimit = 50;
|
||||||
|
for (int i = 0; i < addressLabelCount; i += paginateLimit) {
|
||||||
|
final labelIds = await getAddressLabels(walletId)
|
||||||
|
.offset(i)
|
||||||
|
.limit(paginateLimit)
|
||||||
|
.idProperty()
|
||||||
|
.findAll();
|
||||||
|
await isar.addressLabels.deleteAll(labelIds);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> deleteTransactionNotes(String walletId) async {
|
||||||
|
final noteCount = await getTransactionNotes(walletId).count();
|
||||||
|
await isar.writeTxn(() async {
|
||||||
|
const paginateLimit = 50;
|
||||||
|
for (int i = 0; i < noteCount; i += paginateLimit) {
|
||||||
|
final labelIds = await getTransactionNotes(walletId)
|
||||||
|
.offset(i)
|
||||||
|
.limit(paginateLimit)
|
||||||
|
.idProperty()
|
||||||
|
.findAll();
|
||||||
|
await isar.transactionNotes.deleteAll(labelIds);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -388,6 +388,8 @@ class WalletsService extends ChangeNotifier {
|
||||||
|
|
||||||
// delete wallet data in main db
|
// delete wallet data in main db
|
||||||
await MainDB.instance.deleteWalletBlockchainData(walletId);
|
await MainDB.instance.deleteWalletBlockchainData(walletId);
|
||||||
|
await MainDB.instance.deleteAddressLabels(walletId);
|
||||||
|
await MainDB.instance.deleteTransactionNotes(walletId);
|
||||||
|
|
||||||
// box data may currently still be read/written to if wallet was refreshing
|
// box data may currently still be read/written to if wallet was refreshing
|
||||||
// when delete was requested so instead of deleting now we mark the wallet
|
// when delete was requested so instead of deleting now we mark the wallet
|
||||||
|
|
Loading…
Reference in a new issue