use main db provider

This commit is contained in:
julian 2023-04-03 10:55:10 -06:00
parent 5d1ee78452
commit ce7b222fa1
2 changed files with 13 additions and 7 deletions

View file

@ -2,10 +2,10 @@ import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/svg.dart';
import 'package:isar/isar.dart';
import 'package:stackwallet/db/main_db.dart';
import 'package:stackwallet/models/isar/models/isar_models.dart';
import 'package:stackwallet/pages/receive_view/addresses/address_details_view.dart';
import 'package:stackwallet/pages_desktop_specific/addresses/sub_widgets/desktop_address_list.dart';
import 'package:stackwallet/providers/db/main_db_provider.dart';
import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/theme/stack_colors.dart';
@ -45,8 +45,11 @@ class _DesktopWalletAddressesViewState
@override
void initState() {
addressCollectionWatcher =
MainDB.instance.isar.addresses.watchLazy(fireImmediately: true);
addressCollectionWatcher = ref
.read(mainDBProvider)
.isar
.addresses
.watchLazy(fireImmediately: true);
addressCollectionWatcher.listen((_) => _onAddressCollectionWatcherEvent());
super.initState();

View file

@ -2,10 +2,10 @@ import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/svg.dart';
import 'package:isar/isar.dart';
import 'package:stackwallet/db/main_db.dart';
import 'package:stackwallet/models/isar/models/isar_models.dart';
import 'package:stackwallet/pages/receive_view/addresses/address_card.dart';
import 'package:stackwallet/pages_desktop_specific/addresses/desktop_wallet_addresses_view.dart';
import 'package:stackwallet/providers/db/main_db_provider.dart';
import 'package:stackwallet/providers/global/wallets_provider.dart';
import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/constants.dart';
@ -41,7 +41,8 @@ class _DesktopAddressListState extends ConsumerState<DesktopAddressList> {
List<Id> _search(String term) {
if (term.isEmpty) {
return MainDB.instance
return ref
.read(mainDBProvider)
.getAddresses(widget.walletId)
.filter()
.group((q) => q
@ -60,7 +61,8 @@ class _DesktopAddressListState extends ConsumerState<DesktopAddressList> {
.findAllSync();
}
final labels = MainDB.instance
final labels = ref
.read(mainDBProvider)
.getAddressLabels(widget.walletId)
.filter()
.group(
@ -82,7 +84,8 @@ class _DesktopAddressListState extends ConsumerState<DesktopAddressList> {
return [];
}
return MainDB.instance
return ref
.read(mainDBProvider)
.getAddresses(widget.walletId)
.filter()
.anyOf<AddressLabel, Address>(