removeTransactions method

  1. @override
Future<void> removeTransactions(
  1. List<String>? transactionIds
)
override

Remove transactions by ID should only be used for deleting a wallet if transactionIds is null, all transactions for the wallet should be removed!

Implementation

@override
Future<void> removeTransactions(List<String>? transactionIds) async {
  await dbRdy;
  final transactionBox = _objectBox.store.box<DbWalletTransaction>();

  if (transactionIds == null || transactionIds.isEmpty) {
    await transactionBox.removeAllAsync();
    return;
  }

  final query = transactionBox
      .query(DbWalletTransaction_.id.oneOf(transactionIds))
      .build();

  try {
    final transactionsToRemove = query.find();
    if (transactionsToRemove.isNotEmpty) {
      transactionBox
          .removeMany(transactionsToRemove.map((t) => t.dbId).toList());
    }
  } finally {
    query.close();
  }
}