aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJP Dillingham <jpdillingham@gmail.com>2021-06-06 22:28:04 -0500
committerJP Dillingham <jpdillingham@gmail.com>2021-06-06 22:28:04 -0500
commitcd55d0ae21a7b34fb71944aa3e44e14ff0e3c029 (patch)
tree329ba5be24b96a75069eecb5483987c287bc4d63 /src
parent1e713798fd4324d4513e66f7dbeb1a1bb16691a5 (diff)
downloadslskd-cd55d0ae21a7b34fb71944aa3e44e14ff0e3c029.tar.gz
update filters on input
Diffstat (limited to 'src')
-rw-r--r--src/web/src/components/Search/Search.js11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/web/src/components/Search/Search.js b/src/web/src/components/Search/Search.js
index 42b26195..73670e34 100644
--- a/src/web/src/components/Search/Search.js
+++ b/src/web/src/components/Search/Search.js
@@ -32,7 +32,7 @@ const initialState = {
hiddenResults: [],
hideLocked: true,
fetching: false,
- resultFilters: undefined
+ resultFilters: ''
};
const sortOptions = {
@@ -72,6 +72,10 @@ class Search extends Component {
this.setState({ searchPhrase: data.value });
}
+ onResultFilterChange = (event, data) => {
+ this.setState({ resultFilters: data.value }, () => this.saveState());
+ }
+
saveState = () => {
try {
localStorage.setItem('soulseek-example-search-state', JSON.stringify({ ...this.state, results: [] }));
@@ -188,7 +192,7 @@ class Search extends Component {
}
render = () => {
- let { searchState, searchStatus, results = [], displayCount, resultSort, hideNoFreeSlots, hideLocked, hiddenResults = [], fetching } = this.state;
+ let { searchState, searchStatus, results = [], displayCount, resultSort, hideNoFreeSlots, hideLocked, hiddenResults = [], fetching, resultFilters } = this.state;
let pending = fetching || searchState === 'pending';
const sortedAndFilteredResults = this.sortAndFilterResults();
@@ -255,6 +259,9 @@ class Search extends Component {
<Input
label='Filters'
className='search-filter'
+ value={resultFilters}
+ onChange={this.onResultFilterChange}
+ action={!!resultFilters && { icon: 'x', color: 'red', onClick: () => this.setState({ resultFilters: '' }) }}
/>
</Segment> : <PlaceholderSegment icon='search'/>
}