From 47cf15741c7df723ca07d2d112e72284facd1186 Mon Sep 17 00:00:00 2001 From: Akinwale Ariwodola Date: Mon, 2 Sep 2019 14:15:48 +0100 Subject: [PATCH 1/2] better featured search result item handling --- src/component/claimList/view.js | 7 ++++++- src/component/fileListItem/view.js | 21 +++++++++++++++++---- src/page/publish/view.js | 30 ++++++++++++++---------------- src/page/search/view.js | 8 +------- 4 files changed, 38 insertions(+), 28 deletions(-) diff --git a/src/component/claimList/view.js b/src/component/claimList/view.js index 3f447d1..208e8c6 100644 --- a/src/component/claimList/view.js +++ b/src/component/claimList/view.js @@ -204,7 +204,12 @@ class ClaimList extends React.PureComponent { const options = this.buildClaimSearchOptions(); const claimSearchKey = createNormalizedClaimSearchKey(options); - const uris = claimSearchByQuery[claimSearchKey]; + let uris = claimSearchByQuery[claimSearchKey]; + + if (uris) { + // temporary workaround for missing short_urls + uris = uris.filter(uri => uri && uri.length > 0); + } if (Constants.ORIENTATION_VERTICAL === orientation) { return ( diff --git a/src/component/fileListItem/view.js b/src/component/fileListItem/view.js index 98f2d66..849feeb 100644 --- a/src/component/fileListItem/view.js +++ b/src/component/fileListItem/view.js @@ -3,6 +3,7 @@ import { normalizeURI, parseURI } from 'lbry-redux'; import { ActivityIndicator, Platform, Text, TouchableOpacity, View } from 'react-native'; import { navigateToUri, formatBytes } from 'utils/helper'; import Colors from 'styles/colors'; +import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api import DateTime from 'component/dateTime'; import FileItemMedia from 'component/fileItemMedia'; import Icon from 'react-native-vector-icons/FontAwesome5'; @@ -42,8 +43,13 @@ class FileListItem extends React.PureComponent { } defaultOnPress = () => { - const { autoplay, navigation, uri, shortUrl } = this.props; - navigateToUri(navigation, shortUrl || uri, { autoplay }); + const { autoplay, claim, featuredResult, navigation, uri, shortUrl } = this.props; + + if (featuredResult && !claim) { + navigation.navigate({ routeName: Constants.DRAWER_ROUTE_PUBLISH, params: { vanityUrl: uri } }); + } else { + navigateToUri(navigation, shortUrl || uri, { autoplay }); + } }; onPressHandler = () => { @@ -111,7 +117,7 @@ class FileListItem extends React.PureComponent { // shouldHide = 'channel' === claim.value_type; } - if (shouldHide || (!isResolvingUri && !claim) || (featuredResult && !isResolvingUri && !claim && !title && !name)) { + if (shouldHide || (!isResolvingUri && !claim && !featuredResult)) { return null; } @@ -130,7 +136,7 @@ class FileListItem extends React.PureComponent { style={fileListStyle.thumbnail} duration={duration} resizeMode="cover" - title={title || name} + title={title || name || normalizeURI(uri).substring(7)} thumbnail={thumbnail} /> {selected && ( @@ -167,6 +173,13 @@ class FileListItem extends React.PureComponent { {isRewardContent && } )} + + {featuredResult && !isResolving && !claim && ( + + Nothing here. Claim this address! + + )} + {channel && !hideChannel && ( 0) { + const { claimName } = parseURI(vanityUrl); + this.setState({ + name: claimName, + hasEditedContentAddress: true, + vanityUrlSet: true, + }); } } }); @@ -234,6 +242,7 @@ class PublishPage extends React.PureComponent { title, currentThumbnailUri: thumbnailUrl, uploadedThumbnailUri: thumbnailUrl, + vanityUrlSet: false, }, () => { this.handleNameChange(name); @@ -380,7 +389,7 @@ class PublishPage extends React.PureComponent { { currentMedia: media, title: null, // no title autogeneration (user will fill this in) - name: this.formatNameForTitle(name), + name: this.state.hasEditedContentAddress ? this.state.name : this.formatNameForTitle(name), currentPhase: Constants.PHASE_DETAILS, }, () => this.handleNameChange(this.state.name) @@ -426,6 +435,8 @@ class PublishPage extends React.PureComponent { tags: [], selectedChannel: null, uploadedThumbnailUri: null, + + vanityUrlSet: false, }, () => { // reset thumbnail @@ -512,19 +523,6 @@ class PublishPage extends React.PureComponent { }); }; - handleUploadPressed = () => { - DocumentPicker.pick({ type: [DocumentPicker.types.allFiles] }) - .then(file => { - // console.log(file); - }) - .catch(error => { - if (!DocumentPicker.isCancel(error)) { - // notify the user - // console.log(error); - } - }); - }; - getRandomFileId = () => { // generate a random id for a photo or recorded video between 1 and 20 (for creating thumbnails) const id = Math.floor(Math.random() * (20 - 2)) + 1; diff --git a/src/page/search/view.js b/src/page/search/view.js index 5fe147c..d6580c0 100644 --- a/src/page/search/view.js +++ b/src/page/search/view.js @@ -101,13 +101,7 @@ class SearchPage extends React.PureComponent { const { currentUri } = this.state; return ( - navigateToUri(navigation, this.state.currentUri)} - /> + ); }; -- 2.45.3 From c7f2b78b926359f58974212f0866d0097dfecd96 Mon Sep 17 00:00:00 2001 From: Akinwale Ariwodola Date: Thu, 5 Sep 2019 15:53:25 +0100 Subject: [PATCH 2/2] fixes as per review --- src/component/fileListItem/view.js | 4 ++-- src/page/publish/view.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/component/fileListItem/view.js b/src/component/fileListItem/view.js index 849feeb..96b5119 100644 --- a/src/component/fileListItem/view.js +++ b/src/component/fileListItem/view.js @@ -46,7 +46,7 @@ class FileListItem extends React.PureComponent { const { autoplay, claim, featuredResult, navigation, uri, shortUrl } = this.props; if (featuredResult && !claim) { - navigation.navigate({ routeName: Constants.DRAWER_ROUTE_PUBLISH, params: { vanityUrl: uri } }); + navigation.navigate({ routeName: Constants.DRAWER_ROUTE_PUBLISH, params: { vanityUrl: uri.trim() } }); } else { navigateToUri(navigation, shortUrl || uri, { autoplay }); } @@ -176,7 +176,7 @@ class FileListItem extends React.PureComponent { {featuredResult && !isResolving && !claim && ( - Nothing here. Claim this address! + Nothing here. Publish something! )} diff --git a/src/page/publish/view.js b/src/page/publish/view.js index fe3b2d7..2f74a3c 100644 --- a/src/page/publish/view.js +++ b/src/page/publish/view.js @@ -184,7 +184,7 @@ class PublishPage extends React.PureComponent { const { editMode, claimToEdit, vanityUrl } = navigation.state.params; if (editMode) { this.prepareEdit(claimToEdit); - } else if (vanityUrl && vanityUrl.trim().length > 0) { + } else if (vanityUrl) { const { claimName } = parseURI(vanityUrl); this.setState({ name: claimName, -- 2.45.3