From f49898b1e20c8be4f9a827dd84ede22520bc6884 Mon Sep 17 00:00:00 2001 From: Andrey Molochko <36672245+AndreyMolochko@users.noreply.github.com> Date: Tue, 19 Nov 2024 16:27:05 +0300 Subject: [PATCH] fix bug with switching network, change local for network (#624) Co-authored-by: Andrey Malochka --- .../nekoton_related/connection_service/network_presets.dart | 2 +- lib/feature/wallet/view/wallet_page_model.dart | 3 +++ lib/feature/wallet/view/wallet_page_widget.dart | 6 ++++-- lib/feature/wallet/view/wallet_page_wm.dart | 5 +++++ lib/feature/wallet/view/wallet_view.dart | 3 +++ .../wallet/widgets/account_asset_tab/account_asset_tab.dart | 3 +++ .../widgets/account_asset_tab/account_asset_tab_cubit.dart | 2 +- lib/feature/wallet/widgets/wallet_bottom_panel.dart | 3 +++ 8 files changed, 23 insertions(+), 4 deletions(-) diff --git a/lib/app/service/nekoton_related/connection_service/network_presets.dart b/lib/app/service/nekoton_related/connection_service/network_presets.dart index b63bba143..63a9bd8fd 100644 --- a/lib/app/service/nekoton_related/connection_service/network_presets.dart +++ b/lib/app/service/nekoton_related/connection_service/network_presets.dart @@ -66,7 +66,7 @@ final _venomPresets = [ final _tychoPresets = [ ConnectionData.protoPreset( id: tychoTestnetProtoID, - name: 'Tycho', + name: 'Tycho Testnet', group: 'tycho_testnet', endpoint: 'https://rpc-testnet.tychoprotocol.com/', networkType: NetworkType.tycho, diff --git a/lib/feature/wallet/view/wallet_page_model.dart b/lib/feature/wallet/view/wallet_page_model.dart index 09bed2699..20ff43d58 100644 --- a/lib/feature/wallet/view/wallet_page_model.dart +++ b/lib/feature/wallet/view/wallet_page_model.dart @@ -17,6 +17,9 @@ class WalletPageModel extends ElementaryModel { Stream get currentAccount => _currentAccountsService.currentActiveAccountStream; + Stream get transportStrategy => + _nekotonRepository.currentTransportStream; + Future isNewUser() async { return _storageService.getValue(StorageKey.userWithNewWallet()); } diff --git a/lib/feature/wallet/view/wallet_page_widget.dart b/lib/feature/wallet/view/wallet_page_widget.dart index 42768e7ad..c2645627b 100644 --- a/lib/feature/wallet/view/wallet_page_widget.dart +++ b/lib/feature/wallet/view/wallet_page_widget.dart @@ -15,10 +15,11 @@ class WalletPageWidget extends ElementaryWidget { @override Widget build(WalletPageWidgetModel wm) { return Scaffold( - body: DoubleSourceBuilder( + body: TripleSourceBuilder( firstSource: wm.currentAccount, secondSource: wm.isShowingNewTokens, - builder: (_, currentAccount, isShowingNewTokens) { + thirdSource: wm.transportStrategy, + builder: (_, currentAccount, isShowingNewTokens, transport) { return currentAccount?.let( (value) => StateNotifierBuilder( listenableState: wm.isShowingBadge, @@ -30,6 +31,7 @@ class WalletPageWidget extends ElementaryWidget { isShowingNewTokens: isShowingNewTokens ?? false, finishedBackupCallback: wm.hideShowingBadge, confirmImportCallback: wm.hideNewTokensLabel, + manifestUrl: transport?.manifestUrl ?? '', ), ), ) ?? diff --git a/lib/feature/wallet/view/wallet_page_wm.dart b/lib/feature/wallet/view/wallet_page_wm.dart index 4e896ee96..1d6492d78 100644 --- a/lib/feature/wallet/view/wallet_page_wm.dart +++ b/lib/feature/wallet/view/wallet_page_wm.dart @@ -32,6 +32,8 @@ class WalletPageWidgetModel late final scrollController = createScrollController(); late final _currentAccount = createNotifierFromStream(model.currentAccount); + late final _transportStrategy = + createNotifierFromStream(model.transportStrategy); late final _isShowingBadgeNotifier = createNotifier(); late final _isShowingNewTokensNotifier = createNotifier(); @@ -39,6 +41,9 @@ class WalletPageWidgetModel ListenableState get currentAccount => _currentAccount; + ListenableState get transportStrategy => + _transportStrategy; + ListenableState get isShowingBadge => _isShowingBadgeNotifier; ListenableState get isShowingNewTokens => _isShowingNewTokensNotifier; diff --git a/lib/feature/wallet/view/wallet_view.dart b/lib/feature/wallet/view/wallet_view.dart index 7621a402e..8cc15ab75 100644 --- a/lib/feature/wallet/view/wallet_view.dart +++ b/lib/feature/wallet/view/wallet_view.dart @@ -14,6 +14,7 @@ class WalletView extends StatelessWidget { required this.isShowingNewTokens, required this.finishedBackupCallback, required this.confirmImportCallback, + required this.manifestUrl, super.key, }); @@ -23,6 +24,7 @@ class WalletView extends StatelessWidget { final bool isShowingNewTokens; final VoidCallback finishedBackupCallback; final VoidCallback confirmImportCallback; + final String manifestUrl; @override Widget build(BuildContext context) { @@ -49,6 +51,7 @@ class WalletView extends StatelessWidget { scrollController: scrollController, isShowingNewTokens: isShowingNewTokens, confirmImportCallback: confirmImportCallback, + manifestUrl: manifestUrl, ), SliverFillRemaining( hasScrollBody: false, diff --git a/lib/feature/wallet/widgets/account_asset_tab/account_asset_tab.dart b/lib/feature/wallet/widgets/account_asset_tab/account_asset_tab.dart index 2b84cc798..450656e73 100644 --- a/lib/feature/wallet/widgets/account_asset_tab/account_asset_tab.dart +++ b/lib/feature/wallet/widgets/account_asset_tab/account_asset_tab.dart @@ -20,16 +20,19 @@ class AccountAssetsTab extends StatelessWidget { required this.account, required this.isShowingNewTokens, required this.confirmImportCallback, + required this.manifestUrl, super.key, }); final KeyAccount account; final bool isShowingNewTokens; final VoidCallback confirmImportCallback; + final String manifestUrl; @override Widget build(BuildContext context) { return BlocProvider( + key: ValueKey(manifestUrl), create: (_) => AccountAssetTabCubit( account, inject(), diff --git a/lib/feature/wallet/widgets/account_asset_tab/account_asset_tab_cubit.dart b/lib/feature/wallet/widgets/account_asset_tab/account_asset_tab_cubit.dart index d1e07c5f6..768f7318f 100644 --- a/lib/feature/wallet/widgets/account_asset_tab/account_asset_tab_cubit.dart +++ b/lib/feature/wallet/widgets/account_asset_tab/account_asset_tab_cubit.dart @@ -32,7 +32,7 @@ class AccountAssetTabCubit extends Cubit { ); }); - if (isShowingNewTokens || true) { + if (isShowingNewTokens) { _searchSubscription = tokenWalletsService .searchTokenWalletsForAddress(tonWallet.address) .reduce((previous, element) => [...previous, ...element]) diff --git a/lib/feature/wallet/widgets/wallet_bottom_panel.dart b/lib/feature/wallet/widgets/wallet_bottom_panel.dart index f126a6643..1df771786 100644 --- a/lib/feature/wallet/widgets/wallet_bottom_panel.dart +++ b/lib/feature/wallet/widgets/wallet_bottom_panel.dart @@ -17,6 +17,7 @@ class WalletBottomPanel extends StatefulWidget { required this.scrollController, required this.isShowingNewTokens, required this.confirmImportCallback, + required this.manifestUrl, super.key, }); @@ -24,6 +25,7 @@ class WalletBottomPanel extends StatefulWidget { final ScrollController scrollController; final bool isShowingNewTokens; final VoidCallback confirmImportCallback; + final String manifestUrl; @override State createState() => _WalletBottomPanelState(); @@ -85,6 +87,7 @@ class _WalletBottomPanelState extends State { account: widget.currentAccount, isShowingNewTokens: widget.isShowingNewTokens, confirmImportCallback: widget.confirmImportCallback, + manifestUrl: widget.manifestUrl, ), WalletBottomPanelTab.transactions => AccountTransactionsTab( account: widget.currentAccount,