Skip to content

Commit

Permalink
chore: added minimizer to go back to browsers in android
Browse files Browse the repository at this point in the history
  • Loading branch information
ignaciosantise committed Jul 18, 2024
1 parent d5c46f8 commit 376ee02
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 19 deletions.
1 change: 1 addition & 0 deletions wallets/rn_cli_wallet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"@craftzdog/react-native-buffer": "6.0.5",
"@ethersproject/shims": "5.7.0",
"@json-rpc-tools/utils": "1.7.6",
"@kangfenmao/react-native-minimizer": "1.0.4",
"@react-native-async-storage/async-storage": "1.24.0",
"@react-native-clipboard/clipboard": "1.14.1",
"@react-native-community/netinfo": "11.3.2",
Expand Down
43 changes: 24 additions & 19 deletions wallets/rn_cli_wallet/src/utils/LinkingUtils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {Linking} from 'react-native';
import {Linking, Platform} from 'react-native';
import Toast from 'react-native-toast-message';
import Minimizer from '@kangfenmao/react-native-minimizer';

interface redirect {
native?: string;
Expand All @@ -12,13 +13,30 @@ interface Props {
isLinkMode?: boolean;
}

const goBackOrToast = () => {
if (Platform.OS === 'android') {
Toast.show({
type: 'success',
text1: 'Success!',
text2: 'Redirecting to the dapp',
});
Minimizer.goBack();
} else {
Toast.show({
type: 'success',
text1: 'Success!',
text2: 'Please go back to the dapp',
});
}
};

export const handleRedirect = ({peerRedirect, isLinkMode}: Props) => {
try {
if (isLinkMode) {
Toast.show({
type: 'success',
text1: 'Success!',
text2: 'Redirecting to the dapp...',
text2: 'Redirecting to the dapp',
});
return;
}
Expand All @@ -29,28 +47,15 @@ export const handleRedirect = ({peerRedirect, isLinkMode}: Props) => {
if (peerRedirect?.universal) {
Linking.openURL(peerRedirect.universal);
} else {
Toast.show({
type: 'success',
text1: 'Success!',
text2: 'Please go back to the dapp',
});
goBackOrToast();
}
});
} else if (peerRedirect?.universal) {
Linking.openURL(peerRedirect.universal);
} else {
Toast.show({
type: 'success',
text1: 'Success!',
text2: 'Please go back to the dapp',
});
goBackOrToast();
}
} catch (error) {
console.log(error);
Toast.show({
type: 'success',
text1: 'Success!',
text2: 'Please go back to the dapp',
});
} catch (error: any) {
goBackOrToast();
}
};
11 changes: 11 additions & 0 deletions wallets/rn_cli_wallet/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2640,6 +2640,16 @@ __metadata:
languageName: node
linkType: hard

"@kangfenmao/react-native-minimizer@npm:1.0.4":
version: 1.0.4
resolution: "@kangfenmao/react-native-minimizer@npm:1.0.4"
peerDependencies:
react: "*"
react-native: "*"
checksum: b752ac3635acff719e3bd1bdcc7a47833b121c14d6133e0cc83fd5280b45a22b93b19795b9d6f7f07e6796a21af22dc7473fc14dbefd261da3765e54122b481b
languageName: node
linkType: hard

"@nicolo-ribaudo/eslint-scope-5-internals@npm:5.1.1-v1":
version: 5.1.1-v1
resolution: "@nicolo-ribaudo/eslint-scope-5-internals@npm:5.1.1-v1"
Expand Down Expand Up @@ -13179,6 +13189,7 @@ __metadata:
"@craftzdog/react-native-buffer": 6.0.5
"@ethersproject/shims": 5.7.0
"@json-rpc-tools/utils": 1.7.6
"@kangfenmao/react-native-minimizer": 1.0.4
"@react-native-async-storage/async-storage": 1.24.0
"@react-native-clipboard/clipboard": 1.14.1
"@react-native-community/netinfo": 11.3.2
Expand Down

0 comments on commit 376ee02

Please sign in to comment.