1 ? 'auto 200px' : 1 }}>
- {matchingCategories.map((key) => {
- return (
-
-
{key}
-
- {matchingFilters[key] && matchingFilters[key].map((filter: any) => (
-
onFilterClick({ ...filter, value: [''] })}>
-
- {filter.label}
-
- )
- )}
-
+
+
1 ? 'auto 200px' : 1 }}
+ >
+ {matchingCategories.map((key) => {
+ return (
+
- { showSearchList && (
+
+ {matchingFilters[key] &&
+ matchingFilters[key].map((filter: any) => (
+
onFilterClick({ ...filter, value: [''] })}
+ >
+
+ {filter.label}
+
+ ))}
+
+
+ );
+ })}
+
+ {showSearchList && (
{isResultEmpty && !fetchingFilterSearchList ? (
@@ -109,30 +125,38 @@ function FilterModal(props: Props) {
No Suggestions Found
- ) : Object.keys(filterSearchList).map((key, index) => {
- const filter = filterSearchList[key];
- const option = filtersMap[key];
- return option ? (
-
-
{option.label}
-
- {filter.map((f, i) => (
-
onFilterSearchClick({ type: key, value: f.value })}
- >
-
-
{f.value}
-
- ))}
+ ) : (
+ Object.keys(filterSearchList).map((key, index) => {
+ const filter = filterSearchList[key];
+ const option = filtersMap[key];
+ return option ? (
+
+
+ {option.label}
+
+
+ {filter.map((f, i) => (
+
onFilterSearchClick({ type: key, value: f.value })}
+ >
+
+
+ {f.value}
+
+
+ ))}
+
-
- ) : <>>;
- })}
+ ) : (
+ <>>
+ );
+ })
+ )}
)}
@@ -141,14 +165,15 @@ function FilterModal(props: Props) {
}
export default connect((state: any, props: any) => {
- return ({
- filters: props.isLive ? state.getIn([ 'search', 'filterListLive' ]) : state.getIn([ 'search', 'filterList' ]),
- filterSearchList: props.isLive ? state.getIn([ 'liveSearch', 'filterSearchList' ]) : state.getIn([ 'search', 'filterSearchList' ]),
- // filterSearchList: state.getIn([ 'search', 'filterSearchList' ]),
- // liveFilterSearchList: state.getIn([ 'liveSearch', 'filterSearchList' ]),
- // metaOptions: state.getIn([ 'customFields', 'list' ]),
+ return {
+ filters: props.isLive
+ ? state.getIn(['search', 'filterListLive'])
+ : state.getIn(['search', 'filterList']),
+ filterSearchList: props.isLive
+ ? state.getIn(['liveSearch', 'filterSearchList'])
+ : state.getIn(['search', 'filterSearchList']),
fetchingFilterSearchList: props.isLive
- ? state.getIn(['liveSearch', 'fetchFilterSearch', 'loading'])
- : state.getIn(['search', 'fetchFilterSearch', 'loading']),
- })
+ ? state.getIn(['liveSearch', 'fetchFilterSearch', 'loading'])
+ : state.getIn(['search', 'fetchFilterSearch', 'loading']),
+ };
})(FilterModal);
diff --git a/frontend/app/components/shared/SessionSearchField/SessionSearchField.tsx b/frontend/app/components/shared/SessionSearchField/SessionSearchField.tsx
index b5c663452..84745c8ba 100644
--- a/frontend/app/components/shared/SessionSearchField/SessionSearchField.tsx
+++ b/frontend/app/components/shared/SessionSearchField/SessionSearchField.tsx
@@ -5,16 +5,27 @@ import FilterModal from 'Shared/Filters/FilterModal';
import { debounce } from 'App/utils';
import { assist as assistRoute, isRoute } from 'App/routes';
import { addFilterByKeyAndValue, fetchFilterSearch } from 'Duck/search';
+import {
+ addFilterByKeyAndValue as liveAddFilterByKeyAndValue,
+ fetchFilterSearch as liveFetchFilterSearch,
+} from 'Duck/liveSearch';
const ASSIST_ROUTE = assistRoute();
interface Props {
fetchFilterSearch: (query: any) => void;
addFilterByKeyAndValue: (key: string, value: string) => void;
- filterSearchListLive: any;
+ liveAddFilterByKeyAndValue: (key: string, value: string) => void;
filterSearchList: any;
+ liveFetchFilterSearch: any;
}
function SessionSearchField(props: Props) {
- const debounceFetchFilterSearch = React.useCallback(debounce(props.fetchFilterSearch, 1000), []);
+ const isLive =
+ isRoute(ASSIST_ROUTE, window.location.pathname) ||
+ window.location.pathname.includes('multiview');
+ const debounceFetchFilterSearch = React.useCallback(
+ debounce(isLive ? props.liveFetchFilterSearch : props.fetchFilterSearch, 1000),
+ []
+ );
const [showModal, setShowModal] = useState(false);
const [searchQuery, setSearchQuery] = useState('');
@@ -24,7 +35,9 @@ function SessionSearchField(props: Props) {
};
const onAddFilter = (filter: any) => {
- props.addFilterByKeyAndValue(filter.key, filter.value);
+ isLive
+ ? props.liveAddFilterByKeyAndValue(filter.key, filter.value)
+ : props.addFilterByKeyAndValue(filter.key, filter.value);
};
return (
@@ -47,10 +60,7 @@ function SessionSearchField(props: Props) {
searchQuery={searchQuery}
isMainSearch={true}
onFilterClick={onAddFilter}
- isLive={
- isRoute(ASSIST_ROUTE, window.location.pathname) ||
- window.location.pathname.includes('multiview')
- }
+ isLive={isLive}
/>
)}
@@ -58,10 +68,9 @@ function SessionSearchField(props: Props) {
);
}
-export default connect(
- (state: any) => ({
- filterSearchList: state.getIn(['search', 'filterSearchList']),
- filterSearchListLive: state.getIn(['liveSearch', 'filterSearchList']),
- }),
- { addFilterByKeyAndValue, fetchFilterSearch }
-)(SessionSearchField);
+export default connect(null, {
+ addFilterByKeyAndValue,
+ fetchFilterSearch,
+ liveFetchFilterSearch,
+ liveAddFilterByKeyAndValue,
+})(SessionSearchField);