getSearchQueryString: customizations for SIMPLE_SITE.
- This change makes it work for both Desktop and Odysee. When merging back to Odysee, just take the file from `master` (barring any changes from someone else). - Given that we'll be opening up the search filter for Odysee, the only "simple site" customization that was back-ported is `free_only=true`.
This commit is contained in:
parent
c73ba60ef5
commit
1ee05d1f7f
1 changed files with 12 additions and 3 deletions
|
@ -1,5 +1,6 @@
|
|||
// @flow
|
||||
import { SEARCH_OPTIONS } from 'constants/search';
|
||||
import { SIMPLE_SITE } from 'config';
|
||||
|
||||
const DEFAULT_SEARCH_RESULT_FROM = 0;
|
||||
const DEFAULT_SEARCH_SIZE = 20;
|
||||
|
@ -32,6 +33,7 @@ export function updateQueryParam(uri: string, key: string, value: string) {
|
|||
}
|
||||
|
||||
export const getSearchQueryString = (query: string, options: any = {}) => {
|
||||
const FORCE_FREE_ONLY = SIMPLE_SITE;
|
||||
const encodedQuery = encodeURIComponent(query);
|
||||
const queryParams = [
|
||||
`s=${encodedQuery}`,
|
||||
|
@ -47,9 +49,8 @@ export const getSearchQueryString = (query: string, options: any = {}) => {
|
|||
queryParams.push(`claimType=${claimType}`);
|
||||
|
||||
/*
|
||||
* Due to limitations in lighthouse, we can't pass
|
||||
* the mediaType parameter when searching for
|
||||
* channels or "everything".
|
||||
* Due to limitations in lighthouse, we can't pass the mediaType parameter
|
||||
* when searching for channels or "everything".
|
||||
*/
|
||||
if (!claimType.includes(SEARCH_OPTIONS.INCLUDE_CHANNELS)) {
|
||||
queryParams.push(
|
||||
|
@ -79,5 +80,13 @@ export const getSearchQueryString = (query: string, options: any = {}) => {
|
|||
});
|
||||
}
|
||||
|
||||
if (FORCE_FREE_ONLY) {
|
||||
const index = queryParams.findIndex((q) => q.startsWith('free_only'));
|
||||
if (index > -1) {
|
||||
queryParams.splice(index, 1);
|
||||
}
|
||||
queryParams.push(`free_only=true`);
|
||||
}
|
||||
|
||||
return queryParams.join('&');
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue