From f9e012398606a85d286087f3e94bf8b95a52df55 Mon Sep 17 00:00:00 2001 From: fragosti Date: Wed, 14 Nov 2018 16:27:27 -0800 Subject: feat: make onUnlockWalletClick different based on ON --- .../containers/connected_account_payment_method.ts | 27 ++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'packages/instant/src/containers') diff --git a/packages/instant/src/containers/connected_account_payment_method.ts b/packages/instant/src/containers/connected_account_payment_method.ts index 69c2ddf19..beaaccf2f 100644 --- a/packages/instant/src/containers/connected_account_payment_method.ts +++ b/packages/instant/src/containers/connected_account_payment_method.ts @@ -3,10 +3,16 @@ import { connect } from 'react-redux'; import { Dispatch } from 'redux'; import { PaymentMethod, PaymentMethodProps } from '../components/payment_method'; +import { + COINBASE_WALLET_ANDROID_APP_STORE_URL, + COINBASE_WALLET_IOS_APP_STORE_URL, + COINBASE_WALLET_SITE_URL, +} from '../constants'; import { Action, actions } from '../redux/actions'; import { asyncData } from '../redux/async_data'; import { State } from '../redux/reducer'; -import { Network, Omit, ProviderState, StandardSlidingPanelContent } from '../types'; +import { Network, Omit, OperatingSystem, ProviderState, StandardSlidingPanelContent } from '../types'; +import { envUtil } from '../util/env'; export interface ConnectedAccountPaymentMethodProps {} @@ -49,7 +55,24 @@ const mergeProps = ( onInstallWalletClick: connectedDispatch.onInstallWalletClick, walletName: connectedState.providerState.name, onUnlockWalletClick: () => { - connectedDispatch.unlockWalletAndDispatchToStore(connectedState.providerState); + const isMobile = envUtil.isMobileOperatingSystem(); + if (!isMobile) { + connectedDispatch.unlockWalletAndDispatchToStore(connectedState.providerState); + return; + } + const operatingSystem = envUtil.getOperatingSystem(); + let url = COINBASE_WALLET_SITE_URL; + switch (operatingSystem) { + case OperatingSystem.Android: + url = COINBASE_WALLET_ANDROID_APP_STORE_URL; + break; + case OperatingSystem.iOS: + url = COINBASE_WALLET_IOS_APP_STORE_URL; + break; + default: + break; + } + window.open(url, '_blank'); }, }); -- cgit v1.2.3 From 4da574560d50f661227ec4d91acf20917c26b17b Mon Sep 17 00:00:00 2001 From: fragosti Date: Thu, 15 Nov 2018 12:40:28 -0800 Subject: fix: remove redundant handler --- .../instant/src/containers/connected_account_payment_method.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'packages/instant/src/containers') diff --git a/packages/instant/src/containers/connected_account_payment_method.ts b/packages/instant/src/containers/connected_account_payment_method.ts index beaaccf2f..eacbadfca 100644 --- a/packages/instant/src/containers/connected_account_payment_method.ts +++ b/packages/instant/src/containers/connected_account_payment_method.ts @@ -22,7 +22,7 @@ interface ConnectedState { } interface ConnectedDispatch { - onInstallWalletClick: () => void; + openInstallWalletPanel: () => void; unlockWalletAndDispatchToStore: (providerState: ProviderState) => void; } @@ -39,7 +39,7 @@ const mapDispatchToProps = ( dispatch: Dispatch, ownProps: ConnectedAccountPaymentMethodProps, ): ConnectedDispatch => ({ - onInstallWalletClick: () => dispatch(actions.openStandardSlidingPanel(StandardSlidingPanelContent.InstallWallet)), + openInstallWalletPanel: () => dispatch(actions.openStandardSlidingPanel(StandardSlidingPanelContent.InstallWallet)), unlockWalletAndDispatchToStore: async (providerState: ProviderState) => asyncData.fetchAccountInfoAndDispatchToStore(providerState, dispatch, true), }); @@ -52,12 +52,12 @@ const mergeProps = ( ...ownProps, network: connectedState.network, account: connectedState.providerState.account, - onInstallWalletClick: connectedDispatch.onInstallWalletClick, walletName: connectedState.providerState.name, - onUnlockWalletClick: () => { + onUnlockWalletClick: () => connectedDispatch.unlockWalletAndDispatchToStore(connectedState.providerState), + onInstallWalletClick: () => { const isMobile = envUtil.isMobileOperatingSystem(); if (!isMobile) { - connectedDispatch.unlockWalletAndDispatchToStore(connectedState.providerState); + connectedDispatch.openInstallWalletPanel(); return; } const operatingSystem = envUtil.getOperatingSystem(); -- cgit v1.2.3