From acbbc66b78566da11faa0fa8c65b44a8d4302c5e Mon Sep 17 00:00:00 2001 From: Akinwale Ariwodola Date: Mon, 3 Feb 2020 07:25:44 +0100 Subject: [PATCH] add nsfw flag --- dist/bundle.es.js | 5 +++-- src/redux/actions/search.js | 8 ++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/dist/bundle.es.js b/dist/bundle.es.js index 0549d59..1c85e26 100644 --- a/dist/bundle.es.js +++ b/dist/bundle.es.js @@ -4055,7 +4055,7 @@ from, isBackgroundSearch = false, options = {}, resolveResults = true) => (dispa }; const doResolvedSearch = (rawQuery, size, // only pass in if you don't want to use the users setting (ex: related content) -from, isBackgroundSearch = false, options = {}) => (dispatch, getState) => { +from, isBackgroundSearch = false, options = {}, nsfw) => (dispatch, getState) => { const query = rawQuery.replace(/^lbry:\/\//i, '').replace(/\//, ' '); if (!query) { @@ -4086,7 +4086,8 @@ from, isBackgroundSearch = false, options = {}) => (dispatch, getState) => { dispatch(doUpdateSearchQuery(query)); } - fetch(`${CONNECTION_STRING}search?resolve=true&${queryWithOptions}`).then(handleFetchResponse).then(data => { + const fetchUrl = nsfw ? `${CONNECTION_STRING}search?resolve=true&${queryWithOptions}` : `${CONNECTION_STRING}search?resolve=true&nsfw=false&${queryWithOptions}`; + fetch(fetchUrl).then(handleFetchResponse).then(data => { const results = []; data.forEach(result => { diff --git a/src/redux/actions/search.js b/src/redux/actions/search.js index e00d7ba..fc17b4b 100644 --- a/src/redux/actions/search.js +++ b/src/redux/actions/search.js @@ -167,7 +167,8 @@ export const doResolvedSearch = ( isBackgroundSearch: boolean = false, options: { related_to?: string, - } = {} + } = {}, + nsfw: boolean ) => (dispatch: Dispatch, getState: GetState) => { const query = rawQuery.replace(/^lbry:\/\//i, '').replace(/\//, ' '); @@ -203,7 +204,10 @@ export const doResolvedSearch = ( dispatch(doUpdateSearchQuery(query)); } - fetch(`${CONNECTION_STRING}search?resolve=true&${queryWithOptions}`) + const fetchUrl = nsfw + ? `${CONNECTION_STRING}search?resolve=true&${queryWithOptions}` + : `${CONNECTION_STRING}search?resolve=true&nsfw=false&${queryWithOptions}`; + fetch(fetchUrl) .then(handleFetchResponse) .then((data: Array) => { const results = [];