mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-16 17:27:39 +00:00
Merge pull request #930 from cypherstack/testing
single coin app wallets list state updating fix
This commit is contained in:
commit
aeb7de8d90
3 changed files with 44 additions and 17 deletions
|
@ -20,6 +20,8 @@ import '../../models/isar/models/ethereum/eth_contract.dart';
|
||||||
import '../../pages_desktop_specific/my_stack_view/dialogs/desktop_expanding_wallet_card.dart';
|
import '../../pages_desktop_specific/my_stack_view/dialogs/desktop_expanding_wallet_card.dart';
|
||||||
import '../../providers/db/main_db_provider.dart';
|
import '../../providers/db/main_db_provider.dart';
|
||||||
import '../../providers/providers.dart';
|
import '../../providers/providers.dart';
|
||||||
|
import '../../services/event_bus/events/wallet_added_event.dart';
|
||||||
|
import '../../services/event_bus/global_event_bus.dart';
|
||||||
import '../../themes/stack_colors.dart';
|
import '../../themes/stack_colors.dart';
|
||||||
import '../../utilities/assets.dart';
|
import '../../utilities/assets.dart';
|
||||||
import '../../utilities/constants.dart';
|
import '../../utilities/constants.dart';
|
||||||
|
@ -111,11 +113,7 @@ class _EthWalletsOverviewState extends ConsumerState<WalletsOverview> {
|
||||||
return element.toLowerCase().contains(term);
|
return element.toLowerCase().contains(term);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
void updateWallets() {
|
||||||
void initState() {
|
|
||||||
_searchController = TextEditingController();
|
|
||||||
searchFieldFocusNode = FocusNode();
|
|
||||||
|
|
||||||
final walletsData =
|
final walletsData =
|
||||||
ref.read(mainDBProvider).isar.walletInfo.where().findAllSync();
|
ref.read(mainDBProvider).isar.walletInfo.where().findAllSync();
|
||||||
walletsData.removeWhere((e) => e.coin != widget.coin);
|
walletsData.removeWhere((e) => e.coin != widget.coin);
|
||||||
|
@ -155,16 +153,40 @@ class _EthWalletsOverviewState extends ConsumerState<WalletsOverview> {
|
||||||
} else {
|
} else {
|
||||||
// add non token wallet tuple to list
|
// add non token wallet tuple to list
|
||||||
for (final data in walletsData) {
|
for (final data in walletsData) {
|
||||||
wallets.add(
|
// desktop single coin apps may cause issues so lets just ignore the error and move on
|
||||||
Tuple2(
|
try {
|
||||||
ref.read(pWallets).getWallet(
|
wallets.add(
|
||||||
data.walletId,
|
Tuple2(
|
||||||
),
|
ref.read(pWallets).getWallet(
|
||||||
[],
|
data.walletId,
|
||||||
),
|
),
|
||||||
);
|
[],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} catch (_) {
|
||||||
|
// lol bandaid for single coin based apps
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
_searchController = TextEditingController();
|
||||||
|
searchFieldFocusNode = FocusNode();
|
||||||
|
|
||||||
|
updateWallets();
|
||||||
|
|
||||||
|
if (AppConfig.isSingleCoinApp) {
|
||||||
|
GlobalEventBus.instance.on<WalletAddedEvent>().listen((_) {
|
||||||
|
updateWallets();
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
if (mounted) {
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
1
lib/services/event_bus/events/wallet_added_event.dart
Normal file
1
lib/services/event_bus/events/wallet_added_event.dart
Normal file
|
@ -0,0 +1 @@
|
||||||
|
class WalletAddedEvent {}
|
|
@ -13,12 +13,10 @@ import 'dart:async';
|
||||||
import 'package:flutter_libmonero/monero/monero.dart' as monero;
|
import 'package:flutter_libmonero/monero/monero.dart' as monero;
|
||||||
import 'package:flutter_libmonero/wownero/wownero.dart' as wownero;
|
import 'package:flutter_libmonero/wownero/wownero.dart' as wownero;
|
||||||
import 'package:isar/isar.dart';
|
import 'package:isar/isar.dart';
|
||||||
|
|
||||||
|
import '../app_config.dart';
|
||||||
import '../db/hive/db.dart';
|
import '../db/hive/db.dart';
|
||||||
import '../db/isar/main_db.dart';
|
import '../db/isar/main_db.dart';
|
||||||
import 'node_service.dart';
|
|
||||||
import 'notifications_service.dart';
|
|
||||||
import 'trade_sent_from_stack_service.dart';
|
|
||||||
import '../app_config.dart';
|
|
||||||
import '../utilities/enums/sync_type_enum.dart';
|
import '../utilities/enums/sync_type_enum.dart';
|
||||||
import '../utilities/flutter_secure_storage_interface.dart';
|
import '../utilities/flutter_secure_storage_interface.dart';
|
||||||
import '../utilities/logger.dart';
|
import '../utilities/logger.dart';
|
||||||
|
@ -28,6 +26,11 @@ import '../wallets/isar/models/wallet_info.dart';
|
||||||
import '../wallets/wallet/impl/epiccash_wallet.dart';
|
import '../wallets/wallet/impl/epiccash_wallet.dart';
|
||||||
import '../wallets/wallet/wallet.dart';
|
import '../wallets/wallet/wallet.dart';
|
||||||
import '../wallets/wallet/wallet_mixin_interfaces/cw_based_interface.dart';
|
import '../wallets/wallet/wallet_mixin_interfaces/cw_based_interface.dart';
|
||||||
|
import 'event_bus/events/wallet_added_event.dart';
|
||||||
|
import 'event_bus/global_event_bus.dart';
|
||||||
|
import 'node_service.dart';
|
||||||
|
import 'notifications_service.dart';
|
||||||
|
import 'trade_sent_from_stack_service.dart';
|
||||||
|
|
||||||
class Wallets {
|
class Wallets {
|
||||||
Wallets._private();
|
Wallets._private();
|
||||||
|
@ -59,6 +62,7 @@ class Wallets {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
_wallets[wallet.walletId] = wallet;
|
_wallets[wallet.walletId] = wallet;
|
||||||
|
GlobalEventBus.instance.fire(WalletAddedEvent());
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> deleteWallet(
|
Future<void> deleteWallet(
|
||||||
|
|
Loading…
Reference in a new issue