getSearchQueryString: add "time_filter" option

This commit is contained in:
infinite-persistence 2021-03-30 13:57:37 +08:00 committed by Sean Yesmunt
parent 2cc049bb83
commit a9cae23d87
3 changed files with 17 additions and 0 deletions

View file

@ -18,6 +18,12 @@ declare type SearchOptions = {
SORT_ACCENDING: string,
SORT_DESCENDING: string,
EXACT: string,
TIME_FILTER: string,
TIME_FILTER_LAST_HOUR: string,
TIME_FILTER_TODAY: string,
TIME_FILTER_THIS_WEEK: string,
TIME_FILTER_THIS_MONTH: string,
TIME_FILTER_THIS_YEAR: string,
};
declare type SearchState = {

View file

@ -25,4 +25,10 @@ export const SEARCH_OPTIONS = {
SORT_ACCENDING: '^release_time',
SORT_DESCENDING: 'release_time',
EXACT: 'exact',
TIME_FILTER: 'time_filter',
TIME_FILTER_LAST_HOUR: 'lasthour',
TIME_FILTER_TODAY: 'today',
TIME_FILTER_THIS_WEEK: 'thisweek',
TIME_FILTER_THIS_MONTH: 'thismonth',
TIME_FILTER_THIS_YEAR: 'thisyear',
};

View file

@ -71,6 +71,11 @@ export const getSearchQueryString = (query: string, options: any = {}) => {
if (sortBy) {
queryParams.push(`${SEARCH_OPTIONS.SORT}=${sortBy}`);
}
const timeFilter = options[SEARCH_OPTIONS.TIME_FILTER];
if (timeFilter) {
queryParams.push(`${SEARCH_OPTIONS.TIME_FILTER}=${timeFilter}`);
}
}
const additionalOptions = {};