Skip to content

Commit

Permalink
wait for mounted on entry
Browse files Browse the repository at this point in the history
  • Loading branch information
estebanmino committed Jun 12, 2020
1 parent 4a4c14b commit 4acafcc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
19 changes: 16 additions & 3 deletions app/components/Views/Entry/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,33 @@ class Entry extends PureComponent {
animation = React.createRef();
animationName = React.createRef();
opacity = new Animated.Value(1);
mounted = false;

async componentDidMount() {
DeeplinkManager.init(this.props.navigation);
this.unsubscribeFromBranch = Branch.subscribe(this.handleDeeplinks);
SplashScreen.hide();
const existingUser = await AsyncStorage.getItem('@MetaMask:existingUser');
if (existingUser !== null) {
await this.unlockKeychain();
} else {
this.animateAndGoTo('OnboardingRootNav');
}
DeeplinkManager.init(this.props.navigation);
this.unsubscribeFromBranch = Branch.subscribe(this.handleDeeplinks);
this.mounted = true;
}

handleDeeplinks = ({ error, params, uri }) => {
waitUntilMounted = async () => {
if (this.mounted) return;
await new Promise(resolve => {
setTimeout(() => {
if (this.mounted) resolve();
else this.waitUntilMounted();
}, 2000);
});
};

handleDeeplinks = async ({ error, params, uri }) => {
await this.waitUntilMounted();
if (error) {
Logger.error(error, 'Error from Branch');
return;
Expand Down
7 changes: 1 addition & 6 deletions app/core/DeeplinkManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ class DeeplinkManager {
params = qs.parse(urlObj.query.substring(1));
}
const { MM_UNIVERSAL_LINK_HOST } = AppConstants;

switch (urlObj.protocol.replace(':', '')) {
case 'http':
case 'https':
Expand All @@ -71,11 +70,7 @@ class DeeplinkManager {

switch (action) {
case 'wc':
params &&
params.uri &&
setTimeout(() => {
WalletConnect.newSession(params.uri, params.redirectUrl, false);
}, 1500);
params && params.uri && WalletConnect.newSession(params.uri, params.redirectUrl, false);
break;
case 'dapp':
this.handleBrowserUrl(
Expand Down

0 comments on commit 4acafcc

Please sign in to comment.