better featured search result item handling #37
4 changed files with 38 additions and 28 deletions
|
@ -204,7 +204,12 @@ class ClaimList extends React.PureComponent {
|
||||||
|
|
||||||
const options = this.buildClaimSearchOptions();
|
const options = this.buildClaimSearchOptions();
|
||||||
const claimSearchKey = createNormalizedClaimSearchKey(options);
|
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) {
|
if (Constants.ORIENTATION_VERTICAL === orientation) {
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { normalizeURI, parseURI } from 'lbry-redux';
|
||||||
import { ActivityIndicator, Platform, Text, TouchableOpacity, View } from 'react-native';
|
import { ActivityIndicator, Platform, Text, TouchableOpacity, View } from 'react-native';
|
||||||
import { navigateToUri, formatBytes } from 'utils/helper';
|
import { navigateToUri, formatBytes } from 'utils/helper';
|
||||||
import Colors from 'styles/colors';
|
import Colors from 'styles/colors';
|
||||||
|
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||||
import DateTime from 'component/dateTime';
|
import DateTime from 'component/dateTime';
|
||||||
import FileItemMedia from 'component/fileItemMedia';
|
import FileItemMedia from 'component/fileItemMedia';
|
||||||
import Icon from 'react-native-vector-icons/FontAwesome5';
|
import Icon from 'react-native-vector-icons/FontAwesome5';
|
||||||
|
@ -42,8 +43,13 @@ class FileListItem extends React.PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultOnPress = () => {
|
defaultOnPress = () => {
|
||||||
const { autoplay, navigation, uri, shortUrl } = this.props;
|
const { autoplay, claim, featuredResult, navigation, uri, shortUrl } = this.props;
|
||||||
navigateToUri(navigation, shortUrl || uri, { autoplay });
|
|
||||||
|
if (featuredResult && !claim) {
|
||||||
|
navigation.navigate({ routeName: Constants.DRAWER_ROUTE_PUBLISH, params: { vanityUrl: uri } });
|
||||||
|
} else {
|
||||||
|
navigateToUri(navigation, shortUrl || uri, { autoplay });
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
onPressHandler = () => {
|
onPressHandler = () => {
|
||||||
|
@ -111,7 +117,7 @@ class FileListItem extends React.PureComponent {
|
||||||
// shouldHide = 'channel' === claim.value_type;
|
// shouldHide = 'channel' === claim.value_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shouldHide || (!isResolvingUri && !claim) || (featuredResult && !isResolvingUri && !claim && !title && !name)) {
|
if (shouldHide || (!isResolvingUri && !claim && !featuredResult)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +136,7 @@ class FileListItem extends React.PureComponent {
|
||||||
style={fileListStyle.thumbnail}
|
style={fileListStyle.thumbnail}
|
||||||
duration={duration}
|
duration={duration}
|
||||||
resizeMode="cover"
|
resizeMode="cover"
|
||||||
title={title || name}
|
title={title || name || normalizeURI(uri).substring(7)}
|
||||||
thumbnail={thumbnail}
|
thumbnail={thumbnail}
|
||||||
/>
|
/>
|
||||||
{selected && (
|
{selected && (
|
||||||
|
@ -167,6 +173,13 @@ class FileListItem extends React.PureComponent {
|
||||||
{isRewardContent && <Icon style={fileListStyle.rewardIcon} name="award" size={12} />}
|
{isRewardContent && <Icon style={fileListStyle.rewardIcon} name="award" size={12} />}
|
||||||
when would you have a uri but not a name for a file list item? when would you have a uri but not a name for a file list item?
This applies when there's no claim for a featured search item. The values for This applies when there's no claim for a featured search item. The values for `title` and `name` are obtained from the claim.
|
|||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{featuredResult && !isResolving && !claim && (
|
||||||
|
<View style={fileListStyle.titleContainer}>
|
||||||
|
<Text style={fileListStyle.featuredTitle}>Nothing here. Claim this address!</Text>
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
|
||||||
{channel && !hideChannel && (
|
{channel && !hideChannel && (
|
||||||
<Link
|
<Link
|
||||||
style={fileListStyle.publisher}
|
style={fileListStyle.publisher}
|
||||||
|
|
|
@ -19,6 +19,7 @@ import {
|
||||||
isNameValid,
|
isNameValid,
|
||||||
buildURI,
|
buildURI,
|
||||||
normalizeURI,
|
normalizeURI,
|
||||||
|
parseURI,
|
||||||
regexInvalidURI,
|
regexInvalidURI,
|
||||||
CLAIM_VALUES,
|
CLAIM_VALUES,
|
||||||
LICENSES,
|
LICENSES,
|
||||||
|
@ -27,7 +28,6 @@ import {
|
||||||
} from 'lbry-redux';
|
} from 'lbry-redux';
|
||||||
import { RNCamera } from 'react-native-camera';
|
import { RNCamera } from 'react-native-camera';
|
||||||
import { generateCombination } from 'gfycat-style-urls';
|
import { generateCombination } from 'gfycat-style-urls';
|
||||||
import DocumentPicker from 'react-native-document-picker';
|
|
||||||
import RNFS from 'react-native-fs';
|
import RNFS from 'react-native-fs';
|
||||||
import Button from 'component/button';
|
import Button from 'component/button';
|
||||||
import ChannelSelector from 'component/channelSelector';
|
import ChannelSelector from 'component/channelSelector';
|
||||||
|
@ -124,6 +124,7 @@ class PublishPage extends React.PureComponent {
|
||||||
tags: [],
|
tags: [],
|
||||||
selectedChannel: null,
|
selectedChannel: null,
|
||||||
uploadedThumbnailUri: null,
|
uploadedThumbnailUri: null,
|
||||||
|
vanityUrlSet: false,
|
||||||
|
|
||||||
// other
|
// other
|
||||||
publishStarted: false,
|
publishStarted: false,
|
||||||
|
@ -180,9 +181,16 @@ class PublishPage extends React.PureComponent {
|
||||||
|
|
||||||
// Check if this is an edit action
|
// Check if this is an edit action
|
||||||
if (navigation.state.params) {
|
if (navigation.state.params) {
|
||||||
const { editMode, claimToEdit } = navigation.state.params;
|
const { editMode, claimToEdit, vanityUrl } = navigation.state.params;
|
||||||
if (editMode) {
|
if (editMode) {
|
||||||
this.prepareEdit(claimToEdit);
|
this.prepareEdit(claimToEdit);
|
||||||
|
} else if (vanityUrl && vanityUrl.trim().length > 0) {
|
||||||
|
const { claimName } = parseURI(vanityUrl);
|
||||||
|
this.setState({
|
||||||
|
name: claimName,
|
||||||
|
hasEditedContentAddress: true,
|
||||||
|
vanityUrlSet: true,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -234,6 +242,7 @@ class PublishPage extends React.PureComponent {
|
||||||
title,
|
title,
|
||||||
currentThumbnailUri: thumbnailUrl,
|
currentThumbnailUri: thumbnailUrl,
|
||||||
uploadedThumbnailUri: thumbnailUrl,
|
uploadedThumbnailUri: thumbnailUrl,
|
||||||
|
vanityUrlSet: false,
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
this.handleNameChange(name);
|
this.handleNameChange(name);
|
||||||
|
@ -380,7 +389,7 @@ class PublishPage extends React.PureComponent {
|
||||||
{
|
{
|
||||||
currentMedia: media,
|
currentMedia: media,
|
||||||
title: null, // no title autogeneration (user will fill this in)
|
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,
|
currentPhase: Constants.PHASE_DETAILS,
|
||||||
},
|
},
|
||||||
() => this.handleNameChange(this.state.name)
|
() => this.handleNameChange(this.state.name)
|
||||||
|
@ -426,6 +435,8 @@ class PublishPage extends React.PureComponent {
|
||||||
tags: [],
|
tags: [],
|
||||||
selectedChannel: null,
|
selectedChannel: null,
|
||||||
uploadedThumbnailUri: null,
|
uploadedThumbnailUri: null,
|
||||||
|
|
||||||
|
vanityUrlSet: false,
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
// reset thumbnail
|
// 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 = () => {
|
getRandomFileId = () => {
|
||||||
// generate a random id for a photo or recorded video between 1 and 20 (for creating thumbnails)
|
// 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;
|
const id = Math.floor(Math.random() * (20 - 2)) + 1;
|
||||||
|
|
|
@ -101,13 +101,7 @@ class SearchPage extends React.PureComponent {
|
||||||
const { currentUri } = this.state;
|
const { currentUri } = this.state;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FileListItem
|
<FileListItem uri={currentUri} featuredResult style={searchStyle.featuredResultItem} navigation={navigation} />
|
||||||
uri={currentUri}
|
|
||||||
featuredResult
|
|
||||||
style={searchStyle.featuredResultItem}
|
|
||||||
navigation={navigation}
|
|
||||||
onPress={() => navigateToUri(navigation, this.state.currentUri)}
|
|
||||||
/>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue
if 0.40 fixes this, want to just make the switch?