From e8f973531b72d50b7bc20fe20c67a7049fc2db78 Mon Sep 17 00:00:00 2001 From: Akinwale Ariwodola Date: Wed, 6 Jun 2018 09:25:51 +0100 Subject: [PATCH] set the unique navigation keys for the file pages to the URIs. --- app/src/component/AppNavigator.js | 2 +- app/src/component/fileItem/view.js | 2 +- .../transactionList/internal/transaction-list-item.js | 2 +- app/src/component/uriBar/view.js | 10 ++++++---- app/src/page/splash/view.js | 2 +- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/app/src/component/AppNavigator.js b/app/src/component/AppNavigator.js index 925b9175..8305af8d 100644 --- a/app/src/component/AppNavigator.js +++ b/app/src/component/AppNavigator.js @@ -181,7 +181,7 @@ class AppWithNavigationState extends React.Component { if (evt.url) { const navigateAction = NavigationActions.navigate({ routeName: 'File', - key: 'filePage', + key: evt.url, params: { uri: evt.url } }); dispatch(navigateAction); diff --git a/app/src/component/fileItem/view.js b/app/src/component/fileItem/view.js index 378b2dc3..4e418bdb 100644 --- a/app/src/component/fileItem/view.js +++ b/app/src/component/fileItem/view.js @@ -61,7 +61,7 @@ class FileItem extends React.PureComponent { if (NativeModules.Mixpanel) { NativeModules.Mixpanel.track('Discover Tap', { Uri: uri }); } - navigation.navigate({ routeName: 'File', key: 'filePage', params: { uri } }); + navigation.navigate({ routeName: 'File', key: uri, params: { uri } }); } }> diff --git a/app/src/component/transactionList/internal/transaction-list-item.js b/app/src/component/transactionList/internal/transaction-list-item.js index 0dd3b18c..711dbcba 100644 --- a/app/src/component/transactionList/internal/transaction-list-item.js +++ b/app/src/component/transactionList/internal/transaction-list-item.js @@ -25,7 +25,7 @@ class TransactionListItem extends React.PureComponent { style={transactionListStyle.link} onPress={() => navigation && navigation.navigate({ routeName: 'File', - key: 'filePage', + key: evt.Url, params: { uri: buildURI({ claimName: name, claimId }) }}) } text={name} /> diff --git a/app/src/component/uriBar/view.js b/app/src/component/uriBar/view.js index 0fb69d2b..8b70774c 100644 --- a/app/src/component/uriBar/view.js +++ b/app/src/component/uriBar/view.js @@ -1,6 +1,6 @@ // @flow import React from 'react'; -import { SEARCH_TYPES, isNameValid, normalizeURI } from 'lbry-redux'; +import { SEARCH_TYPES, isNameValid, isURIValid, normalizeURI } from 'lbry-redux'; import { FlatList, Keyboard, TextInput, View } from 'react-native'; import UriBarItem from './internal/uri-bar-item'; import uriBarStyle from '../../styles/uriBar'; @@ -52,7 +52,8 @@ class UriBar extends React.PureComponent { if (SEARCH_TYPES.SEARCH === type) { navigation.navigate({ routeName: 'Search', key: 'searchPage', params: { searchQuery: value }}); } else { - navigation.navigate({ routeName: 'File', key: 'filePage', params: { uri: normalizeURI(value) }}); + const uri = normalizeURI(value); + navigation.navigate({ routeName: 'File', key: uri, params: { uri }}); } } @@ -104,8 +105,9 @@ class UriBar extends React.PureComponent { onSubmitEditing={() => { if (this.state.inputText) { let inputText = this.state.inputText; - if (isNameValid(inputText)) { - navigation.navigate({ routeName: 'File', key: 'filePage', params: { uri: normalizeURI(inputText) }}); + if (isNameValid(inputText) || isURIValid(inputText)) { + const uri = normalizeURI(inputText); + navigation.navigate({ routeName: 'File', key: uri, params: { uri }}); } else { // Open the search page with the query populated navigation.navigate({ routeName: 'Search', key: 'searchPage', params: { searchQuery: inputText }}); diff --git a/app/src/page/splash/view.js b/app/src/page/splash/view.js index 99d91a92..b1318cab 100644 --- a/app/src/page/splash/view.js +++ b/app/src/page/splash/view.js @@ -54,7 +54,7 @@ class SplashScreen extends React.PureComponent { navigation.dispatch(resetAction); if (this.state.launchUrl) { - navigation.navigate({ routeName: 'File', key: 'filePage', params: { uri: this.state.launchUrl } }); + navigation.navigate({ routeName: 'File', key: this.state.launchUrl, params: { uri: this.state.launchUrl } }); } }); return;