Skip to content

Commit

Permalink
fix bug with switching network, change local for network (#624)
Browse files Browse the repository at this point in the history
Co-authored-by: Andrey Malochka <[email protected]>
  • Loading branch information
AndreyMolochko and Andrey Malochka authored Nov 19, 2024
1 parent e7ca864 commit f49898b
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions lib/feature/wallet/view/wallet_page_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ class WalletPageModel extends ElementaryModel {
Stream<KeyAccount?> get currentAccount =>
_currentAccountsService.currentActiveAccountStream;

Stream<TransportStrategy> get transportStrategy =>
_nekotonRepository.currentTransportStream;

Future<bool?> isNewUser() async {
return _storageService.getValue(StorageKey.userWithNewWallet());
}
Expand Down
6 changes: 4 additions & 2 deletions lib/feature/wallet/view/wallet_page_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ class WalletPageWidget extends ElementaryWidget<WalletPageWidgetModel> {
@override
Widget build(WalletPageWidgetModel wm) {
return Scaffold(
body: DoubleSourceBuilder<KeyAccount?, bool>(
body: TripleSourceBuilder<KeyAccount?, bool, TransportStrategy>(
firstSource: wm.currentAccount,
secondSource: wm.isShowingNewTokens,
builder: (_, currentAccount, isShowingNewTokens) {
thirdSource: wm.transportStrategy,
builder: (_, currentAccount, isShowingNewTokens, transport) {
return currentAccount?.let(
(value) => StateNotifierBuilder(
listenableState: wm.isShowingBadge,
Expand All @@ -30,6 +31,7 @@ class WalletPageWidget extends ElementaryWidget<WalletPageWidgetModel> {
isShowingNewTokens: isShowingNewTokens ?? false,
finishedBackupCallback: wm.hideShowingBadge,
confirmImportCallback: wm.hideNewTokensLabel,
manifestUrl: transport?.manifestUrl ?? '',
),
),
) ??
Expand Down
5 changes: 5 additions & 0 deletions lib/feature/wallet/view/wallet_page_wm.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,18 @@ class WalletPageWidgetModel
late final scrollController = createScrollController();

late final _currentAccount = createNotifierFromStream(model.currentAccount);
late final _transportStrategy =
createNotifierFromStream(model.transportStrategy);
late final _isShowingBadgeNotifier = createNotifier<bool>();
late final _isShowingNewTokensNotifier = createNotifier<bool>();

StreamSubscription<PressBottomNavigationEvent>? _pressWalletSubscribtion;

ListenableState<KeyAccount?> get currentAccount => _currentAccount;

ListenableState<TransportStrategy> get transportStrategy =>
_transportStrategy;

ListenableState<bool> get isShowingBadge => _isShowingBadgeNotifier;

ListenableState<bool> get isShowingNewTokens => _isShowingNewTokensNotifier;
Expand Down
3 changes: 3 additions & 0 deletions lib/feature/wallet/view/wallet_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class WalletView extends StatelessWidget {
required this.isShowingNewTokens,
required this.finishedBackupCallback,
required this.confirmImportCallback,
required this.manifestUrl,
super.key,
});

Expand All @@ -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) {
Expand All @@ -49,6 +51,7 @@ class WalletView extends StatelessWidget {
scrollController: scrollController,
isShowingNewTokens: isShowingNewTokens,
confirmImportCallback: confirmImportCallback,
manifestUrl: manifestUrl,
),
SliverFillRemaining(
hasScrollBody: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<AccountAssetTabCubit>(
key: ValueKey(manifestUrl),
create: (_) => AccountAssetTabCubit(
account,
inject<TokenWalletsService>(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class AccountAssetTabCubit extends Cubit<AccountAssetTabState> {
);
});

if (isShowingNewTokens || true) {
if (isShowingNewTokens) {
_searchSubscription = tokenWalletsService
.searchTokenWalletsForAddress(tonWallet.address)
.reduce((previous, element) => [...previous, ...element])
Expand Down
3 changes: 3 additions & 0 deletions lib/feature/wallet/widgets/wallet_bottom_panel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ class WalletBottomPanel extends StatefulWidget {
required this.scrollController,
required this.isShowingNewTokens,
required this.confirmImportCallback,
required this.manifestUrl,
super.key,
});

final KeyAccount currentAccount;
final ScrollController scrollController;
final bool isShowingNewTokens;
final VoidCallback confirmImportCallback;
final String manifestUrl;

@override
State<WalletBottomPanel> createState() => _WalletBottomPanelState();
Expand Down Expand Up @@ -85,6 +87,7 @@ class _WalletBottomPanelState extends State<WalletBottomPanel> {
account: widget.currentAccount,
isShowingNewTokens: widget.isShowingNewTokens,
confirmImportCallback: widget.confirmImportCallback,
manifestUrl: widget.manifestUrl,
),
WalletBottomPanelTab.transactions => AccountTransactionsTab(
account: widget.currentAccount,
Expand Down

0 comments on commit f49898b

Please sign in to comment.