From 78ab2a795bb15d3e27fbc3205fec24c5dc0b5f1f Mon Sep 17 00:00:00 2001 From: Mark Beamer Jr Date: Wed, 20 Jun 2018 19:08:51 -0400 Subject: [PATCH] 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')}