diff --git a/lib/pages/address_book_views/subviews/contact_details_view.dart b/lib/pages/address_book_views/subviews/contact_details_view.dart index 0ab6ebba9..5459f01a1 100644 --- a/lib/pages/address_book_views/subviews/contact_details_view.dart +++ b/lib/pages/address_book_views/subviews/contact_details_view.dart @@ -2,8 +2,8 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/models/contact.dart'; -import 'package:stackwallet/models/paymint/transactions_model.dart'; +import 'package:isar/isar.dart'; +import 'package:stackwallet/models/isar/models/isar_models.dart'; import 'package:stackwallet/notifications/show_flush_bar.dart'; import 'package:stackwallet/pages/address_book_views/subviews/add_new_contact_address_view.dart'; import 'package:stackwallet/pages/address_book_views/subviews/edit_contact_address_view.dart'; @@ -15,7 +15,6 @@ import 'package:stackwallet/services/coins/manager.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/clipboard_interface.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/enums/flush_bar_type.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/widgets/background.dart'; @@ -50,15 +49,6 @@ class _ContactDetailsViewState extends ConsumerState { List> _cachedTransactions = []; - bool _contactHasAddress(String address, Contact contact) { - for (final entry in contact.addresses) { - if (entry.address == address) { - return true; - } - } - return false; - } - Future>> _filteredTransactionsByContact( List managers, ) async { @@ -69,18 +59,17 @@ class _ContactDetailsViewState extends ConsumerState { List> result = []; for (final manager in managers) { - final transactions = (await manager.transactionData) - .getAllTransactions() - .values - .toList() - .where((e) => _contactHasAddress(e.address, contact)); + final transactions = await manager.db.transactions + .filter() + .anyOf(contact.addresses.map((e) => e.address), + (q, String e) => q.addressEqualTo(e)) + .sortByTimestampDesc() + .findAll(); for (final tx in transactions) { result.add(Tuple2(manager.walletId, tx)); } } - // sort by date - result.sort((a, b) => b.item2.timestamp - a.item2.timestamp); return result; }