fixed isPlayable to only play for video or audio.

This commit is contained in:
Mark Beamer Jr 2018-06-18 23:36:15 -04:00 committed by Sean Yesmunt
parent 6c26a13e15
commit 78055ad0d1
8 changed files with 46 additions and 14 deletions

View file

@ -6,6 +6,7 @@ const select = (state, props) => ({
uris: makeSelectSearchUris(props.query)(state),
downloadUris: selectSearchDownloadUris(props.query)(state),
isSearching: selectIsSearching(state),
resultCount: makeSelectClientSetting(settings.RESULT_COUNT)(state),
});
const perform = () => ({});

View file

@ -11,6 +11,7 @@ type Props = {
isSearching: boolean,
uris: ?Array<string>,
downloadUris: ?Array<string>,
resultCount: number,
};
class FileListSearch extends React.PureComponent<Props> {

View file

@ -7,6 +7,8 @@ import {
doBlurSearchInput,
doSearch,
} from 'lbry-redux';
import { makeSelectClientSetting } from 'redux/selectors/settings';
import * as settings from 'constants/settings';
import { doNavigate } from 'redux/actions/navigation';
import Wunderbar from './view';
@ -21,12 +23,13 @@ const select = state => {
return {
...searchState,
wunderbarValue,
resultCount: makeSelectClientSetting(settings.RESULT_COUNT)(state),
};
};
const perform = dispatch => ({
onSearch: query => {
dispatch(doSearch(query, 30)); // Hard coding this for now until https://github.com/lbryio/lbry-app/pull/1639 is merged
onSearch: (query, size) => {
dispatch(doSearch(query, size));
dispatch(doNavigate(`/search`, { query }));
},
onSubmit: (uri, extraParams) => dispatch(doNavigate('/show', { uri, ...extraParams })),

View file

@ -15,6 +15,7 @@ type Props = {
suggestions: Array<string>,
doFocus: () => void,
doBlur: () => void,
resultCount: number,
};
class WunderBar extends React.PureComponent<Props> {
@ -45,7 +46,7 @@ class WunderBar extends React.PureComponent<Props> {
}
handleSubmit(value: string, suggestion?: { value: string, type: string }) {
const { onSubmit, onSearch } = this.props;
const { onSubmit, onSearch, resultCount } = this.props;
const query = value.trim();
const getParams = () => {
const parts = query.split('?');
@ -61,7 +62,7 @@ class WunderBar extends React.PureComponent<Props> {
// User selected a suggestion
if (suggestion) {
if (suggestion.type === 'search') {
onSearch(query);
onSearch(query, resultCount);
} else {
const params = getParams();
const uri = normalizeURI(query);
@ -78,7 +79,7 @@ class WunderBar extends React.PureComponent<Props> {
const params = getParams();
onSubmit(uri, params);
} catch (e) {
onSearch(query);
onSearch(query, resultCount);
}
}

View file

@ -13,3 +13,4 @@ export const THEME = 'theme';
export const THEMES = 'themes';
export const AUTOMATIC_DARK_MODE_ENABLED = 'automaticDarkModeEnabled';
export const AUTOPLAY = 'autoplay';
export const RESULT_COUNT = 'resultCount';

View file

@ -27,6 +27,7 @@ const select = state => ({
languages: selectLanguages(state),
automaticDarkModeEnabled: makeSelectClientSetting(settings.AUTOMATIC_DARK_MODE_ENABLED)(state),
autoplay: makeSelectClientSetting(settings.AUTOPLAY)(state),
resultCount: makeSelectClientSetting(settings.RESULT_COUNT)(state),
});
const perform = dispatch => ({
@ -37,4 +38,7 @@ const perform = dispatch => ({
changeLanguage: newLanguage => dispatch(doChangeLanguage(newLanguage)),
});
export default connect(select, perform)(SettingsPage);
export default connect(
select,
perform
)(SettingsPage);

View file

@ -20,7 +20,7 @@ type DaemonSettings = {
type Props = {
setDaemonSetting: (string, boolean | string | Price) => void,
setClientSetting: (string, boolean | string | Price) => void,
setClientSetting: (string, boolean | string | number | Price) => void,
clearCache: () => Promise<any>,
getThemes: () => void,
daemonSettings: DaemonSettings,
@ -32,6 +32,7 @@ type Props = {
themes: Array<string>,
automaticDarkModeEnabled: boolean,
autoplay: boolean,
resultCount: number,
};
type State = {
@ -57,6 +58,7 @@ class SettingsPage extends React.PureComponent<Props, State> {
(this: any).onAutoplayChange = this.onAutoplayChange.bind(this);
(this: any).clearCache = this.clearCache.bind(this);
// (this: any).onLanguageChange = this.onLanguageChange.bind(this)
(this: any).onSearchResultCountChange = this.onSearchResultCountChange.bind(this);
}
componentDidMount() {
@ -117,6 +119,11 @@ class SettingsPage extends React.PureComponent<Props, State> {
this.props.setClientSetting(settings.SHOW_UNAVAILABLE, event.target.checked);
}
onSearchResultCountChange(event: SyntheticInputEvent<*>) {
const count = event.target.value;
this.props.setClientSetting(settings.RESULT_COUNT, count);
}
setDaemonSetting(name: string, value: boolean | string | Price) {
this.props.setDaemonSetting(name, value);
}
@ -145,6 +152,7 @@ class SettingsPage extends React.PureComponent<Props, State> {
themes,
automaticDarkModeEnabled,
autoplay,
resultCount,
} = this.props;
const noDaemonSettings = !daemonSettings || Object.keys(daemonSettings).length === 0;
@ -253,13 +261,6 @@ class SettingsPage extends React.PureComponent<Props, State> {
checked={autoplay}
postfix={__('Autoplay media files')}
/>
<FormField
type="checkbox"
name="show_unavailable"
onChange={this.onShowUnavailableChange}
checked={showUnavailable}
postfix={__('Show unavailable content in search results')}
/>
<FormField
type="checkbox"
name="show_nsfw"
@ -271,6 +272,25 @@ class SettingsPage extends React.PureComponent<Props, State> {
)}
/>
</section>
<section className="card card--section">
<div className="card__title">{__('Search Settings')}</div>
<FormField
type="number"
name="result_count"
min={1}
max={1000}
value={resultCount}
onChange={this.onSearchResultCountChange}
postfix={__('The number of search results presented')}
/>
<FormField
type="checkbox"
name="show_unavailable"
onChange={this.onShowUnavailableChange}
checked={showUnavailable}
postfix={__('Show unavailable content in search results')}
/>
</section>
<section className="card card--section">
<div className="card__title">{__('Share Diagnostic Data')}</div>
<FormField

View file

@ -25,6 +25,7 @@ const defaultState = {
themes: getLocalStorageSetting(SETTINGS.THEMES, []),
automaticDarkModeEnabled: getLocalStorageSetting(SETTINGS.AUTOMATIC_DARK_MODE_ENABLED, false),
autoplay: getLocalStorageSetting(SETTINGS.AUTOPLAY, false),
resultCount: Number(getLocalStorageSetting(SETTINGS.RESULT_COUNT, 10)),
},
isNight: false,
languages: {},