Merge pull request #263 from lbryio/fix-search
submit search queries from the omnibar on the search page
This commit is contained in:
commit
becf21b7ea
2 changed files with 14 additions and 4 deletions
|
@ -72,7 +72,7 @@ class UriBar extends React.PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { navigation, suggestions, updateSearchQuery, value } = this.props;
|
const { navigation, onSearchSubmitted, suggestions, updateSearchQuery, value } = this.props;
|
||||||
if (this.state.currentValue === null) {
|
if (this.state.currentValue === null) {
|
||||||
this.setState({ currentValue: value });
|
this.setState({ currentValue: value });
|
||||||
}
|
}
|
||||||
|
@ -116,10 +116,18 @@ class UriBar extends React.PureComponent {
|
||||||
onSubmitEditing={() => {
|
onSubmitEditing={() => {
|
||||||
if (this.state.inputText) {
|
if (this.state.inputText) {
|
||||||
let inputText = this.state.inputText;
|
let inputText = this.state.inputText;
|
||||||
if (isNameValid(inputText) || isURIValid(inputText)) {
|
if (inputText.startsWith('lbry://') && isURIValid(inputText)) {
|
||||||
|
// if it's a URI (lbry://...), open the file page
|
||||||
const uri = normalizeURI(inputText);
|
const uri = normalizeURI(inputText);
|
||||||
navigation.navigate({ routeName: 'File', key: uri, params: { uri }});
|
navigation.navigate({ routeName: 'File', key: uri, params: { uri }});
|
||||||
} else {
|
} else {
|
||||||
|
// Not a URI, default to a search request
|
||||||
|
if (onSearchSubmitted) {
|
||||||
|
// Only the search page sets the onSearchSubmitted prop, so call this prop if set
|
||||||
|
onSearchSubmitted(inputText);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Open the search page with the query populated
|
// Open the search page with the query populated
|
||||||
navigation.navigate({ routeName: 'Search', key: 'searchPage', params: { searchQuery: inputText }});
|
navigation.navigate({ routeName: 'Search', key: 'searchPage', params: { searchQuery: inputText }});
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ class SearchPage extends React.PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { isSearching, navigation, uris, query } = this.props;
|
const { isSearching, navigation, query, search, uris } = this.props;
|
||||||
const { searchQuery } = navigation.state.params;
|
const { searchQuery } = navigation.state.params;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -51,7 +51,9 @@ class SearchPage extends React.PureComponent {
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
{isSearching && <ActivityIndicator size="large" color={Colors.LbryGreen} style={searchStyle.loading} /> }
|
{isSearching && <ActivityIndicator size="large" color={Colors.LbryGreen} style={searchStyle.loading} /> }
|
||||||
<FloatingWalletBalance navigation={navigation} />
|
<FloatingWalletBalance navigation={navigation} />
|
||||||
<UriBar value={searchQuery} navigation={navigation} />
|
<UriBar value={searchQuery}
|
||||||
|
navigation={navigation}
|
||||||
|
onSearchSubmitted={(keywords) => search(keywords)} />
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue