|
|
@ -11,6 +11,7 @@ import type { APIEntity } from 'soapbox/types/entities';
|
|
|
|
const SEARCH_CHANGE = 'SEARCH_CHANGE';
|
|
|
|
const SEARCH_CHANGE = 'SEARCH_CHANGE';
|
|
|
|
const SEARCH_CLEAR = 'SEARCH_CLEAR';
|
|
|
|
const SEARCH_CLEAR = 'SEARCH_CLEAR';
|
|
|
|
const SEARCH_SHOW = 'SEARCH_SHOW';
|
|
|
|
const SEARCH_SHOW = 'SEARCH_SHOW';
|
|
|
|
|
|
|
|
const SEARCH_RESULTS_CLEAR = 'SEARCH_RESULTS_CLEAR';
|
|
|
|
|
|
|
|
|
|
|
|
const SEARCH_FETCH_REQUEST = 'SEARCH_FETCH_REQUEST';
|
|
|
|
const SEARCH_FETCH_REQUEST = 'SEARCH_FETCH_REQUEST';
|
|
|
|
const SEARCH_FETCH_SUCCESS = 'SEARCH_FETCH_SUCCESS';
|
|
|
|
const SEARCH_FETCH_SUCCESS = 'SEARCH_FETCH_SUCCESS';
|
|
|
@ -28,7 +29,11 @@ const changeSearch = (value: string) =>
|
|
|
|
(dispatch: AppDispatch) => {
|
|
|
|
(dispatch: AppDispatch) => {
|
|
|
|
// If backspaced all the way, clear the search
|
|
|
|
// If backspaced all the way, clear the search
|
|
|
|
if (value.length === 0) {
|
|
|
|
if (value.length === 0) {
|
|
|
|
return dispatch(clearSearch());
|
|
|
|
dispatch(clearSearchResults());
|
|
|
|
|
|
|
|
return dispatch({
|
|
|
|
|
|
|
|
type: SEARCH_CHANGE,
|
|
|
|
|
|
|
|
value,
|
|
|
|
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
return dispatch({
|
|
|
|
return dispatch({
|
|
|
|
type: SEARCH_CHANGE,
|
|
|
|
type: SEARCH_CHANGE,
|
|
|
@ -41,6 +46,10 @@ const clearSearch = () => ({
|
|
|
|
type: SEARCH_CLEAR,
|
|
|
|
type: SEARCH_CLEAR,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const clearSearchResults = () => ({
|
|
|
|
|
|
|
|
type: SEARCH_RESULTS_CLEAR,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const submitSearch = (filter?: SearchFilter) =>
|
|
|
|
const submitSearch = (filter?: SearchFilter) =>
|
|
|
|
(dispatch: AppDispatch, getState: () => RootState) => {
|
|
|
|
(dispatch: AppDispatch, getState: () => RootState) => {
|
|
|
|
const value = getState().search.value;
|
|
|
|
const value = getState().search.value;
|
|
|
@ -167,6 +176,7 @@ export {
|
|
|
|
SEARCH_CHANGE,
|
|
|
|
SEARCH_CHANGE,
|
|
|
|
SEARCH_CLEAR,
|
|
|
|
SEARCH_CLEAR,
|
|
|
|
SEARCH_SHOW,
|
|
|
|
SEARCH_SHOW,
|
|
|
|
|
|
|
|
SEARCH_RESULTS_CLEAR,
|
|
|
|
SEARCH_FETCH_REQUEST,
|
|
|
|
SEARCH_FETCH_REQUEST,
|
|
|
|
SEARCH_FETCH_SUCCESS,
|
|
|
|
SEARCH_FETCH_SUCCESS,
|
|
|
|
SEARCH_FETCH_FAIL,
|
|
|
|
SEARCH_FETCH_FAIL,
|
|
|
@ -177,6 +187,7 @@ export {
|
|
|
|
SEARCH_ACCOUNT_SET,
|
|
|
|
SEARCH_ACCOUNT_SET,
|
|
|
|
changeSearch,
|
|
|
|
changeSearch,
|
|
|
|
clearSearch,
|
|
|
|
clearSearch,
|
|
|
|
|
|
|
|
clearSearchResults,
|
|
|
|
submitSearch,
|
|
|
|
submitSearch,
|
|
|
|
fetchSearchRequest,
|
|
|
|
fetchSearchRequest,
|
|
|
|
fetchSearchSuccess,
|
|
|
|
fetchSearchSuccess,
|
|
|
|