From 94bc1b1d8a2f5503e76b7d603da1b33e625cf0e7 Mon Sep 17 00:00:00 2001 From: ahujsak Date: Thu, 28 Mar 2019 08:42:01 -0400 Subject: [PATCH 1/2] new API for deep linking --- src/modules/DeepLinkingManager.js | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/modules/DeepLinkingManager.js b/src/modules/DeepLinkingManager.js index 070eb348616..30fda9f527b 100644 --- a/src/modules/DeepLinkingManager.js +++ b/src/modules/DeepLinkingManager.js @@ -5,10 +5,12 @@ import { Alert } from 'react-native' import { Actions } from 'react-native-router-flux' import { connect } from 'react-redux' import { sprintf } from 'sprintf-js' +import parse from 'url-parse' import { selectWallet } from '../actions/WalletActions.js' -import { SCAN } from '../constants/indexConstants.js' +import { PLUGIN_SPEND, SCAN } from '../constants/indexConstants.js' import s from '../locales/strings.js' +import { buySellPlugins, spendPlugins } from '../modules/UI/scenes/Plugins/plugins' import type { Dispatch } from './ReduxTypes.js' type DeepLinkingManagerStateProps = { @@ -33,11 +35,31 @@ class DeepLinkingManager extends React.Component { componentDidUpdate () { if (Object.keys(this.props.wallets).length > 0 && this.props.deepLinkPending) this.checkForWallet() } + processPluginDeepLink = (parsedUrl: Object) => { + if (parsedUrl.pathname.includes('simplex')) { + const plugins = spendPlugins(false).concat(buySellPlugins(false)) + let i = 0 + for (i; i < plugins.length; i++) { + const plugin = plugins[i] + if (plugin.name === 'Simplex') { + Actions[PLUGIN_SPEND]({ plugin: plugin }) + this.props.markAddressDeepLinkDone() + return + } + } + } + this.props.markAddressDeepLinkDone() + } checkForWallet () { const { addressDeepLinkData } = this.props const { currencyCode } = addressDeepLinkData - + // check to see what we have for a deep link. + const parsedUrl = parse(addressDeepLinkData.uri, {}, false) + if (parsedUrl.hostname === 'plugins') { + this.processPluginDeepLink(parsedUrl) + return + } if (!currencyCode) { Actions[SCAN]() return From 91432b6cba27afe98df170a715ad03ab02d61d90 Mon Sep 17 00:00:00 2001 From: ahujsak Date: Tue, 2 Apr 2019 05:44:26 -0400 Subject: [PATCH 2/2] fix crash --- src/components/scenes/PluginViewYAOBScene.js | 6 +++--- src/locales/strings/enUS.json | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/scenes/PluginViewYAOBScene.js b/src/components/scenes/PluginViewYAOBScene.js index 25ac784f6e1..aca9219ab1b 100644 --- a/src/components/scenes/PluginViewYAOBScene.js +++ b/src/components/scenes/PluginViewYAOBScene.js @@ -170,11 +170,11 @@ class PluginView extends React.Component { const mapStateToProps = state => { const account = CORE_SELECTORS.getAccount(state) const guiWallet = UI_SELECTORS.getSelectedWallet(state) - const coreWallet = CORE_SELECTORS.getWallet(state, guiWallet.id) + const coreWallet = guiWallet && guiWallet.id ? CORE_SELECTORS.getWallet(state, guiWallet.id) : null const coreWallets = state.core.wallets.byId const wallets = state.ui.wallets.byId - const walletName = coreWallet.name - const walletId = coreWallet.id + const walletName = coreWallet ? coreWallet.name : null + const walletId = coreWallet ? coreWallet.id : null const currentState = state return { account, diff --git a/src/locales/strings/enUS.json b/src/locales/strings/enUS.json index 98b919b29bb..5b2945f717b 100644 --- a/src/locales/strings/enUS.json +++ b/src/locales/strings/enUS.json @@ -496,6 +496,6 @@ "error_creating_wallets": "Network timeout occurred trying to create and backup wallets. Please check your network connection and restart app to retry wallet creation.", "edge_login_failed": "Failed to Login", "edge_login_fetching": "Fetching Edge Login info...", - "modal_addressexplorer_message": "Show Address in Blockexplorer?", + "modal_addressexplorer_message": "Show Address in Block Explorer?", "modal_addressexplorer_null": "This currency has no explorer site as of now" -} +} \ No newline at end of file