From 78055ad0d16784ca5dfde90a000544d07718ccd6 Mon Sep 17 00:00:00 2001 From: Mark Beamer Jr Date: Mon, 18 Jun 2018 23:36:15 -0400 Subject: [PATCH 1/4] fixed isPlayable to only play for video or audio. --- .../component/fileListSearch/index.js | 1 + .../component/fileListSearch/view.jsx | 1 + src/renderer/component/wunderbar/index.js | 7 ++-- src/renderer/component/wunderbar/view.jsx | 7 ++-- src/renderer/constants/settings.js | 1 + src/renderer/page/settings/index.js | 6 +++- src/renderer/page/settings/view.jsx | 36 ++++++++++++++----- src/renderer/redux/reducers/settings.js | 1 + 8 files changed, 46 insertions(+), 14 deletions(-) diff --git a/src/renderer/component/fileListSearch/index.js b/src/renderer/component/fileListSearch/index.js index 5f4011e2d..5b6d96713 100644 --- a/src/renderer/component/fileListSearch/index.js +++ b/src/renderer/component/fileListSearch/index.js @@ -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 = () => ({}); diff --git a/src/renderer/component/fileListSearch/view.jsx b/src/renderer/component/fileListSearch/view.jsx index e77e667df..248b0045e 100644 --- a/src/renderer/component/fileListSearch/view.jsx +++ b/src/renderer/component/fileListSearch/view.jsx @@ -11,6 +11,7 @@ type Props = { isSearching: boolean, uris: ?Array, downloadUris: ?Array, + resultCount: number, }; class FileListSearch extends React.PureComponent { diff --git a/src/renderer/component/wunderbar/index.js b/src/renderer/component/wunderbar/index.js index 2332fc81a..27a617452 100644 --- a/src/renderer/component/wunderbar/index.js +++ b/src/renderer/component/wunderbar/index.js @@ -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 })), diff --git a/src/renderer/component/wunderbar/view.jsx b/src/renderer/component/wunderbar/view.jsx index 5c3917a09..cdfc38d4c 100644 --- a/src/renderer/component/wunderbar/view.jsx +++ b/src/renderer/component/wunderbar/view.jsx @@ -15,6 +15,7 @@ type Props = { suggestions: Array, doFocus: () => void, doBlur: () => void, + resultCount: number, }; class WunderBar extends React.PureComponent { @@ -45,7 +46,7 @@ class WunderBar extends React.PureComponent { } 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 { // 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 { const params = getParams(); onSubmit(uri, params); } catch (e) { - onSearch(query); + onSearch(query, resultCount); } } diff --git a/src/renderer/constants/settings.js b/src/renderer/constants/settings.js index 92e9ea543..d27c888de 100644 --- a/src/renderer/constants/settings.js +++ b/src/renderer/constants/settings.js @@ -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'; diff --git a/src/renderer/page/settings/index.js b/src/renderer/page/settings/index.js index 7230cb12d..6368358da 100644 --- a/src/renderer/page/settings/index.js +++ b/src/renderer/page/settings/index.js @@ -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); diff --git a/src/renderer/page/settings/view.jsx b/src/renderer/page/settings/view.jsx index 9823645de..c76fefa1a 100644 --- a/src/renderer/page/settings/view.jsx +++ b/src/renderer/page/settings/view.jsx @@ -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, getThemes: () => void, daemonSettings: DaemonSettings, @@ -32,6 +32,7 @@ type Props = { themes: Array, automaticDarkModeEnabled: boolean, autoplay: boolean, + resultCount: number, }; type State = { @@ -57,6 +58,7 @@ class SettingsPage extends React.PureComponent { (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 { 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 { themes, automaticDarkModeEnabled, autoplay, + resultCount, } = this.props; const noDaemonSettings = !daemonSettings || Object.keys(daemonSettings).length === 0; @@ -253,13 +261,6 @@ class SettingsPage extends React.PureComponent { checked={autoplay} postfix={__('Autoplay media files')} /> - { )} /> +
+
{__('Search Settings')}
+ + +
{__('Share Diagnostic Data')}
Date: Wed, 20 Jun 2018 19:08:51 -0400 Subject: [PATCH 2/4] moved search settings to the search page. --- src/renderer/page/search/index.js | 10 +++++-- src/renderer/page/search/view.jsx | 43 ++++++++++++++++++++++++++++- src/renderer/page/settings/index.js | 2 -- src/renderer/page/settings/view.jsx | 34 ----------------------- 4 files changed, 50 insertions(+), 39 deletions(-) diff --git a/src/renderer/page/search/index.js b/src/renderer/page/search/index.js index f640f75f0..3745f961c 100644 --- a/src/renderer/page/search/index.js +++ b/src/renderer/page/search/index.js @@ -1,16 +1,22 @@ import { connect } from 'react-redux'; -import { selectIsSearching, doUpdateSearchQuery, makeSelectCurrentParam } from 'lbry-redux'; +import * as settings from 'constants/settings'; +import { selectIsSearching, selectSearchValue, doUpdateSearchQuery } from 'lbry-redux'; +import { doSetClientSetting } from 'redux/actions/settings'; import { doNavigate } from 'redux/actions/navigation'; +import { makeSelectClientSetting } from 'redux/selectors/settings'; import SearchPage from './view'; const select = state => ({ isSearching: selectIsSearching(state), - query: makeSelectCurrentParam('query')(state), + query: selectSearchValue(state), + showUnavailable: makeSelectClientSetting(settings.SHOW_UNAVAILABLE)(state), + resultCount: makeSelectClientSetting(settings.RESULT_COUNT)(state), }); const perform = dispatch => ({ navigate: path => dispatch(doNavigate(path)), updateSearchQuery: query => dispatch(doUpdateSearchQuery(query)), + setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)), }); export default connect( diff --git a/src/renderer/page/search/view.jsx b/src/renderer/page/search/view.jsx index b28882adc..dd909d8b3 100644 --- a/src/renderer/page/search/view.jsx +++ b/src/renderer/page/search/view.jsx @@ -1,6 +1,8 @@ // @flow import * as React from 'react'; +import * as settings from 'constants/settings'; import { isURIValid, normalizeURI } from 'lbry-redux'; +import { FormField, FormRow } from 'component/common/form'; import FileTile from 'component/fileTile'; import FileListSearch from 'component/fileListSearch'; import ToolTip from 'component/common/tooltip'; @@ -10,13 +12,52 @@ import * as icons from 'constants/icons'; type Props = { query: ?string, + showUnavailable: boolean, + resultCount: number, + setClientSetting: (string, number | boolean) => void, }; class SearchPage extends React.PureComponent { + constructor() { + super(); + + (this: any).onShowUnavailableChange = this.onShowUnavailableChange.bind(this); + (this: any).onSearchResultCountChange = this.onSearchResultCountChange.bind(this); + } + + onSearchResultCountChange(event: SyntheticInputEvent<*>) { + const count = event.target.value; + this.props.setClientSetting(settings.RESULT_COUNT, count); + } + + onShowUnavailableChange(event: SyntheticInputEvent<*>) { + this.props.setClientSetting(settings.SHOW_UNAVAILABLE, event.target.checked); + } + render() { - const { query } = this.props; + const { query, resultCount, showUnavailable } = this.props; return ( + + + + + + {isURIValid(query) && (
diff --git a/src/renderer/page/settings/index.js b/src/renderer/page/settings/index.js index 6368358da..387b0fb88 100644 --- a/src/renderer/page/settings/index.js +++ b/src/renderer/page/settings/index.js @@ -18,7 +18,6 @@ import SettingsPage from './view'; const select = state => ({ daemonSettings: selectDaemonSettings(state), showNsfw: makeSelectClientSetting(settings.SHOW_NSFW)(state), - showUnavailable: makeSelectClientSetting(settings.SHOW_UNAVAILABLE)(state), instantPurchaseEnabled: makeSelectClientSetting(settings.INSTANT_PURCHASE_ENABLED)(state), instantPurchaseMax: makeSelectClientSetting(settings.INSTANT_PURCHASE_MAX)(state), currentTheme: makeSelectClientSetting(settings.THEME)(state), @@ -27,7 +26,6 @@ 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 => ({ diff --git a/src/renderer/page/settings/view.jsx b/src/renderer/page/settings/view.jsx index c76fefa1a..1bed3cf47 100644 --- a/src/renderer/page/settings/view.jsx +++ b/src/renderer/page/settings/view.jsx @@ -27,12 +27,10 @@ type Props = { showNsfw: boolean, instantPurchaseEnabled: boolean, instantPurchaseMax: Price, - showUnavailable: boolean, currentTheme: string, themes: Array, automaticDarkModeEnabled: boolean, autoplay: boolean, - resultCount: number, }; type State = { @@ -51,14 +49,12 @@ class SettingsPage extends React.PureComponent { (this: any).onKeyFeeChange = this.onKeyFeeChange.bind(this); (this: any).onInstantPurchaseMaxChange = this.onInstantPurchaseMaxChange.bind(this); (this: any).onShowNsfwChange = this.onShowNsfwChange.bind(this); - (this: any).onShowUnavailableChange = this.onShowUnavailableChange.bind(this); (this: any).onShareDataChange = this.onShareDataChange.bind(this); (this: any).onThemeChange = this.onThemeChange.bind(this); (this: any).onAutomaticDarkModeChange = this.onAutomaticDarkModeChange.bind(this); (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() { @@ -115,15 +111,6 @@ class SettingsPage extends React.PureComponent { this.props.setClientSetting(settings.SHOW_NSFW, event.target.checked); } - onShowUnavailableChange(event: SyntheticInputEvent<*>) { - 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); } @@ -147,12 +134,10 @@ class SettingsPage extends React.PureComponent { showNsfw, instantPurchaseEnabled, instantPurchaseMax, - showUnavailable, currentTheme, themes, automaticDarkModeEnabled, autoplay, - resultCount, } = this.props; const noDaemonSettings = !daemonSettings || Object.keys(daemonSettings).length === 0; @@ -272,25 +257,6 @@ class SettingsPage extends React.PureComponent { )} />
-
-
{__('Search Settings')}
- - -
{__('Share Diagnostic Data')}
Date: Fri, 22 Jun 2018 15:18:08 -0400 Subject: [PATCH 3/4] set default search results to 50 --- src/renderer/component/fileListSearch/index.js | 1 - src/renderer/page/search/view.jsx | 6 +++--- src/renderer/redux/reducers/settings.js | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/renderer/component/fileListSearch/index.js b/src/renderer/component/fileListSearch/index.js index 5b6d96713..5f4011e2d 100644 --- a/src/renderer/component/fileListSearch/index.js +++ b/src/renderer/component/fileListSearch/index.js @@ -6,7 +6,6 @@ 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 = () => ({}); diff --git a/src/renderer/page/search/view.jsx b/src/renderer/page/search/view.jsx index dd909d8b3..c2514a37b 100644 --- a/src/renderer/page/search/view.jsx +++ b/src/renderer/page/search/view.jsx @@ -26,7 +26,7 @@ class SearchPage extends React.PureComponent { } onSearchResultCountChange(event: SyntheticInputEvent<*>) { - const count = event.target.value; + const count = Number(event.target.value); this.props.setClientSetting(settings.RESULT_COUNT, count); } @@ -43,7 +43,7 @@ class SearchPage extends React.PureComponent { { name="show_unavailable" onChange={this.onShowUnavailableChange} checked={showUnavailable} - postfix={__('Show unavailable content')} + postfix={__('Include unavailable content')} /> diff --git a/src/renderer/redux/reducers/settings.js b/src/renderer/redux/reducers/settings.js index f3696b625..383b76161 100644 --- a/src/renderer/redux/reducers/settings.js +++ b/src/renderer/redux/reducers/settings.js @@ -25,7 +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)), + resultCount: Number(getLocalStorageSetting(SETTINGS.RESULT_COUNT, 50)), }, isNight: false, languages: {}, -- 2.45.2 From 1a9c2c3d17a0c51969c1bdb0a7d13683cfd42a3e Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Fri, 22 Jun 2018 15:22:28 -0400 Subject: [PATCH 4/4] use query from navigation path instead of active search query for search --- src/renderer/page/search/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/renderer/page/search/index.js b/src/renderer/page/search/index.js index 3745f961c..d47469617 100644 --- a/src/renderer/page/search/index.js +++ b/src/renderer/page/search/index.js @@ -1,6 +1,6 @@ import { connect } from 'react-redux'; import * as settings from 'constants/settings'; -import { selectIsSearching, selectSearchValue, doUpdateSearchQuery } from 'lbry-redux'; +import { selectIsSearching, makeSelectCurrentParam, doUpdateSearchQuery } from 'lbry-redux'; import { doSetClientSetting } from 'redux/actions/settings'; import { doNavigate } from 'redux/actions/navigation'; import { makeSelectClientSetting } from 'redux/selectors/settings'; @@ -8,7 +8,7 @@ import SearchPage from './view'; const select = state => ({ isSearching: selectIsSearching(state), - query: selectSearchValue(state), + query: makeSelectCurrentParam('query')(state), showUnavailable: makeSelectClientSetting(settings.SHOW_UNAVAILABLE)(state), resultCount: makeSelectClientSetting(settings.RESULT_COUNT)(state), }); -- 2.45.2