getSearchQueryString: add "sort_by" options
This commit is contained in:
parent
1ee05d1f7f
commit
dc06e2da99
3 changed files with 12 additions and 0 deletions
3
flow-typed/search.js
vendored
3
flow-typed/search.js
vendored
|
@ -14,6 +14,9 @@ declare type SearchOptions = {
|
|||
MEDIA_TEXT: string,
|
||||
MEDIA_IMAGE: string,
|
||||
MEDIA_APPLICATION: string,
|
||||
SORT: string,
|
||||
SORT_ACCENDING: string,
|
||||
SORT_DESCENDING: string,
|
||||
};
|
||||
|
||||
declare type SearchState = {
|
||||
|
|
|
@ -21,4 +21,7 @@ export const SEARCH_OPTIONS = {
|
|||
MEDIA_TEXT: 'text',
|
||||
MEDIA_IMAGE: 'image',
|
||||
MEDIA_APPLICATION: 'application',
|
||||
SORT: 'sort_by',
|
||||
SORT_ACCENDING: '^release_time',
|
||||
SORT_DESCENDING: 'release_time',
|
||||
};
|
||||
|
|
|
@ -65,11 +65,17 @@ export const getSearchQueryString = (query: string, options: any = {}) => {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
const sortBy = options[SEARCH_OPTIONS.SORT];
|
||||
if (sortBy) {
|
||||
queryParams.push(`${SEARCH_OPTIONS.SORT}=${sortBy}`);
|
||||
}
|
||||
}
|
||||
|
||||
const additionalOptions = {};
|
||||
const { related_to } = options;
|
||||
const { nsfw } = options;
|
||||
|
||||
if (related_to) additionalOptions['related_to'] = related_to;
|
||||
if (nsfw === false) additionalOptions['nsfw'] = false;
|
||||
|
||||
|
|
Loading…
Reference in a new issue