getSearchQueryString: add "sort_by" options

This commit is contained in:
infinite-persistence 2021-03-23 13:52:32 +08:00 committed by Sean Yesmunt
parent 1ee05d1f7f
commit dc06e2da99
3 changed files with 12 additions and 0 deletions

View file

@ -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 = {

View file

@ -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',
};

View file

@ -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;