mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-17 05:41:29 +02:00
Fix deep link handling issue (#1297)
* Update root.dart * Revert "Update root.dart" This reverts commit 5808903aafa81c316eb8a32a462ee18392e08f2f. * Update root.dart * increase delay * fix with mobx reaction * lunchUri fix
This commit is contained in:
@@ -5,6 +5,7 @@ import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/reactions/wallet_connect.dart';
|
||||
import 'package:cake_wallet/utils/device_info.dart';
|
||||
import 'package:cake_wallet/utils/payment_request.dart';
|
||||
import 'package:cw_core/wallet_base.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:cake_wallet/routes.dart';
|
||||
import 'package:cake_wallet/src/screens/auth/auth_page.dart';
|
||||
@@ -12,6 +13,7 @@ import 'package:cake_wallet/store/app_store.dart';
|
||||
import 'package:cake_wallet/store/authentication_store.dart';
|
||||
import 'package:cake_wallet/entities/qr_scanner.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:uni_links/uni_links.dart';
|
||||
import 'package:cake_wallet/src/screens/setup_2fa/setup_2fa_enter_code_page.dart';
|
||||
|
||||
@@ -49,6 +51,7 @@ class RootState extends State<Root> with WidgetsBindingObserver {
|
||||
bool _requestAuth;
|
||||
|
||||
StreamSubscription<Uri?>? stream;
|
||||
ReactionDisposer? _walletReactionDisposer;
|
||||
Uri? launchUri;
|
||||
|
||||
@override
|
||||
@@ -72,6 +75,7 @@ class RootState extends State<Root> with WidgetsBindingObserver {
|
||||
@override
|
||||
void dispose() {
|
||||
stream?.cancel();
|
||||
_walletReactionDisposer?.call();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@@ -169,10 +173,20 @@ class RootState extends State<Root> with WidgetsBindingObserver {
|
||||
);
|
||||
});
|
||||
} else if (_isValidPaymentUri()) {
|
||||
widget.navigatorKey.currentState?.pushNamed(
|
||||
Routes.send,
|
||||
arguments: PaymentRequest.fromUri(launchUri),
|
||||
);
|
||||
if (widget.authenticationStore.state == AuthenticationState.uninitialized) {
|
||||
launchUri = null;
|
||||
} else {
|
||||
if (widget.appStore.wallet == null) {
|
||||
waitForWalletInstance(context, launchUri!);
|
||||
launchUri = null;
|
||||
} else {
|
||||
widget.navigatorKey.currentState?.pushNamed(
|
||||
Routes.send,
|
||||
arguments: PaymentRequest.fromUri(launchUri),
|
||||
);
|
||||
launchUri = null;
|
||||
}
|
||||
}
|
||||
launchUri = null;
|
||||
} else if (isWalletConnectLink) {
|
||||
if (isEVMCompatibleChain(widget.appStore.wallet!.type)) {
|
||||
@@ -233,4 +247,24 @@ class RootState extends State<Root> with WidgetsBindingObserver {
|
||||
fontSize: 16.0,
|
||||
);
|
||||
}
|
||||
|
||||
void waitForWalletInstance(BuildContext context, Uri tempLaunchUri) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (context.mounted) {
|
||||
_walletReactionDisposer = reaction(
|
||||
(_) => widget.appStore.wallet,
|
||||
(WalletBase? wallet) {
|
||||
if (wallet != null) {
|
||||
widget.navigatorKey.currentState?.pushNamed(
|
||||
Routes.send,
|
||||
arguments: PaymentRequest.fromUri(tempLaunchUri),
|
||||
);
|
||||
_walletReactionDisposer?.call();
|
||||
_walletReactionDisposer = null;
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user