Feat block nsfw on search #268
5 changed files with 241 additions and 185 deletions
288
dist/bundle.es.js
vendored
288
dist/bundle.es.js
vendored
|
@ -1071,9 +1071,11 @@ function toQueryString(params) {
|
||||||
return parts.join('&');
|
return parts.join('&');
|
||||||
}
|
}
|
||||||
|
|
||||||
const getSearchQueryString = (query, options = {}, includeUserOptions = false, additionalOptions = {}) => {
|
const getSearchQueryString = (query, options = {}) => {
|
||||||
const encodedQuery = encodeURIComponent(query);
|
const encodedQuery = encodeURIComponent(query);
|
||||||
const queryParams = [`s=${encodedQuery}`, `size=${options.size || DEFAULT_SEARCH_SIZE}`, `from=${options.from || DEFAULT_SEARCH_RESULT_FROM}`];
|
const queryParams = [`s=${encodedQuery}`, `size=${options.size || DEFAULT_SEARCH_SIZE}`, `from=${options.from || DEFAULT_SEARCH_RESULT_FROM}`];
|
||||||
|
const { isBackgroundSearch } = options;
|
||||||
|
const includeUserOptions = typeof isBackgroundSearch === 'undefined' ? false : !isBackgroundSearch;
|
||||||
|
|
||||||
if (includeUserOptions) {
|
if (includeUserOptions) {
|
||||||
const claimType = options[SEARCH_OPTIONS.CLAIM_TYPE];
|
const claimType = options[SEARCH_OPTIONS.CLAIM_TYPE];
|
||||||
|
@ -1085,6 +1087,12 @@ const getSearchQueryString = (query, options = {}, includeUserOptions = false, a
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const additionalOptions = {};
|
||||||
|
const { related_to } = options;
|
||||||
|
const { nsfw } = options;
|
||||||
|
if (related_to) additionalOptions['related_to'] = related_to;
|
||||||
|
if (typeof nsfw !== 'undefined') additionalOptions['nsfw'] = nsfw;
|
||||||
|
|
||||||
if (additionalOptions) {
|
if (additionalOptions) {
|
||||||
Object.keys(additionalOptions).forEach(key => {
|
Object.keys(additionalOptions).forEach(key => {
|
||||||
const option = additionalOptions[key];
|
const option = additionalOptions[key];
|
||||||
|
@ -1443,11 +1451,11 @@ const selectSearchSuggestions = reselect.createSelector(selectSearchValue, selec
|
||||||
|
|
||||||
// Creates a query string based on the state in the search reducer
|
// Creates a query string based on the state in the search reducer
|
||||||
// Can be overrided by passing in custom sizes/from values for other areas pagination
|
// Can be overrided by passing in custom sizes/from values for other areas pagination
|
||||||
const makeSelectQueryWithOptions = (customQuery, customSize, customFrom, isBackgroundSearch = false, // If it's a background search, don't use the users settings
|
|
||||||
additionalOptions = {}) => reselect.createSelector(selectSearchValue, selectSearchOptions, (query, options) => {
|
|
||||||
const size = customSize || options[SEARCH_OPTIONS.RESULT_COUNT];
|
|
||||||
|
|
||||||
const queryString = getSearchQueryString(customQuery || query, _extends$1({}, options, { size, from: customFrom }), !isBackgroundSearch, additionalOptions);
|
|
||||||
|
const makeSelectQueryWithOptions = (customQuery, options) => reselect.createSelector(selectSearchValue, selectSearchOptions, (query, defaultOptions) => {
|
||||||
|
const searchOptions = _extends$1({}, defaultOptions, options);
|
||||||
|
const queryString = getSearchQueryString(customQuery || query, searchOptions);
|
||||||
|
|
||||||
return queryString;
|
return queryString;
|
||||||
});
|
});
|
||||||
|
@ -2249,11 +2257,12 @@ const makeSelectRecommendedContentForUri = uri => reselect.createSelector(makeSe
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const options = { related_to: claim.claim_id };
|
const options = { related_to: claim.claim_id, isBackgroundSearch: true };
|
||||||
|
|
||||||
if (!isMature) {
|
if (!isMature) {
|
||||||
options['nsfw'] = false;
|
options['nsfw'] = false;
|
||||||
}
|
}
|
||||||
const searchQuery = getSearchQueryString(title.replace(/\//, ' '), undefined, undefined, options);
|
const searchQuery = getSearchQueryString(title.replace(/\//, ' '), options);
|
||||||
|
|
||||||
let searchUris = searchUrisByQuery[searchQuery];
|
let searchUris = searchUrisByQuery[searchQuery];
|
||||||
if (searchUris) {
|
if (searchUris) {
|
||||||
|
@ -2326,7 +2335,7 @@ const makeSelectMyStreamUrlsForPage = (page = 1) => reselect.createSelector(sele
|
||||||
|
|
||||||
const selectMyStreamUrlsCount = reselect.createSelector(selectMyClaimUrisWithoutChannels, channels => channels.length);
|
const selectMyStreamUrlsCount = reselect.createSelector(selectMyClaimUrisWithoutChannels, channels => channels.length);
|
||||||
|
|
||||||
const makeSelectResolvedRecommendedContentForUri = (uri, size) => reselect.createSelector(makeSelectClaimForUri(uri), selectResolvedSearchResultsByQuery, (claim, resolvedResultsByQuery) => {
|
const makeSelectResolvedRecommendedContentForUri = (uri, size) => reselect.createSelector(makeSelectClaimForUri(uri), selectResolvedSearchResultsByQuery, makeSelectClaimIsNsfw(uri), (claim, resolvedResultsByQuery, isMature) => {
|
||||||
const atVanityURI = !uri.includes('#');
|
const atVanityURI = !uri.includes('#');
|
||||||
|
|
||||||
let recommendedContent;
|
let recommendedContent;
|
||||||
|
@ -2340,9 +2349,12 @@ const makeSelectResolvedRecommendedContentForUri = (uri, size) => reselect.creat
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const searchQuery = getSearchQueryString(title.replace(/\//, ' '), { size }, undefined, {
|
const options = { related_to: claim.claim_id, isBackgroundSearch: true };
|
||||||
related_to: claim.claim_id
|
if (!isMature) {
|
||||||
});
|
options['nsfw'] = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const searchQuery = getSearchQueryString(title.replace(/\//, ' '), options);
|
||||||
|
|
||||||
let results = resolvedResultsByQuery[searchQuery];
|
let results = resolvedResultsByQuery[searchQuery];
|
||||||
if (results) {
|
if (results) {
|
||||||
|
@ -3968,7 +3980,7 @@ function handleFetchResponse(response) {
|
||||||
return response.status === 200 ? Promise.resolve(response.json()) : Promise.reject(new Error(response.statusText));
|
return response.status === 200 ? Promise.resolve(response.json()) : Promise.reject(new Error(response.statusText));
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
var _extends$8 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
||||||
|
|
||||||
const DEBOUNCED_SEARCH_SUGGESTION_MS = 300;
|
const DEBOUNCED_SEARCH_SUGGESTION_MS = 300;
|
||||||
|
|
||||||
|
@ -4025,9 +4037,10 @@ const doUpdateSearchQuery = (query, shouldSkipSuggestions) => dispatch => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const doSearch = (rawQuery, size, // only pass in if you don't want to use the users setting (ex: related content)
|
const doSearch = (rawQuery, searchOptions) => (dispatch, getState) => {
|
||||||
from, isBackgroundSearch = false, options = {}, resolveResults = true) => (dispatch, getState) => {
|
|
||||||
const query = rawQuery.replace(/^lbry:\/\//i, '').replace(/\//, ' ');
|
const query = rawQuery.replace(/^lbry:\/\//i, '').replace(/\//, ' ');
|
||||||
|
const resolveResults = searchOptions && searchOptions.resolveResults;
|
||||||
|
const isBackgroundSearch = searchOptions && searchOptions.isBackgroundSearch || false;
|
||||||
|
|
||||||
if (!query) {
|
if (!query) {
|
||||||
dispatch({
|
dispatch({
|
||||||
|
@ -4037,7 +4050,8 @@ from, isBackgroundSearch = false, options = {}, resolveResults = true) => (dispa
|
||||||
}
|
}
|
||||||
|
|
||||||
const state = getState();
|
const state = getState();
|
||||||
let queryWithOptions = makeSelectQueryWithOptions(query, size, from, isBackgroundSearch, options)(state);
|
|
||||||
|
let queryWithOptions = makeSelectQueryWithOptions(query, searchOptions)(state);
|
||||||
|
|
||||||
// If we have already searched for something, we don't need to do anything
|
// If we have already searched for something, we don't need to do anything
|
||||||
const urisForQuery = makeSelectSearchUris(queryWithOptions)(state);
|
const urisForQuery = makeSelectSearchUris(queryWithOptions)(state);
|
||||||
|
@ -4108,11 +4122,23 @@ from, isBackgroundSearch = false, options = {}) => (dispatch, getState) => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const optionsWithFrom = _extends$8({
|
||||||
|
size,
|
||||||
|
from,
|
||||||
|
isBackgroundSearch
|
||||||
|
}, options);
|
||||||
|
|
||||||
|
const optionsWithoutFrom = _extends$8({
|
||||||
|
size,
|
||||||
|
isBackgroundSearch
|
||||||
|
}, options);
|
||||||
|
|
||||||
const state = getState();
|
const state = getState();
|
||||||
let queryWithOptions = makeSelectQueryWithOptions(query, size, from, isBackgroundSearch, options)(state);
|
|
||||||
|
let queryWithOptions = makeSelectQueryWithOptions(query, optionsWithFrom)(state);
|
||||||
|
|
||||||
// make from null so that we can maintain a reference to the same query for multiple pages and simply append the found results
|
// make from null so that we can maintain a reference to the same query for multiple pages and simply append the found results
|
||||||
let queryWithoutFrom = makeSelectQueryWithOptions(query, size, null, isBackgroundSearch, options)(state);
|
let queryWithoutFrom = makeSelectQueryWithOptions(query, optionsWithoutFrom)(state);
|
||||||
|
|
||||||
// If we have already searched for something, we don't need to do anything
|
// If we have already searched for something, we don't need to do anything
|
||||||
// TODO: Tweak this check for multiple page results
|
// TODO: Tweak this check for multiple page results
|
||||||
|
@ -4162,7 +4188,7 @@ const doBlurSearchInput = () => dispatch => dispatch({
|
||||||
type: SEARCH_BLUR
|
type: SEARCH_BLUR
|
||||||
});
|
});
|
||||||
|
|
||||||
const doUpdateSearchOptions = newOptions => (dispatch, getState) => {
|
const doUpdateSearchOptions = (newOptions, additionalOptions) => (dispatch, getState) => {
|
||||||
const state = getState();
|
const state = getState();
|
||||||
const searchValue = selectSearchValue(state);
|
const searchValue = selectSearchValue(state);
|
||||||
|
|
||||||
|
@ -4173,7 +4199,7 @@ const doUpdateSearchOptions = newOptions => (dispatch, getState) => {
|
||||||
|
|
||||||
if (searchValue) {
|
if (searchValue) {
|
||||||
// After updating, perform a search with the new options
|
// After updating, perform a search with the new options
|
||||||
dispatch(doSearch(searchValue));
|
dispatch(doSearch(searchValue, additionalOptions));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -4398,7 +4424,7 @@ const doToggleBlockChannel = uri => ({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var _extends$8 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
var _extends$9 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
||||||
|
|
||||||
const reducers = {};
|
const reducers = {};
|
||||||
const defaultState = {
|
const defaultState = {
|
||||||
|
@ -4501,7 +4527,7 @@ reducers[RESOLVE_URIS_STARTED] = (state, action) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
reducers[RESOLVE_URIS_COMPLETED] = (state, action) => {
|
reducers[RESOLVE_URIS_COMPLETED] = (state, action) => {
|
||||||
return _extends$8({}, handleClaimAction(state, action));
|
return _extends$9({}, handleClaimAction(state, action));
|
||||||
};
|
};
|
||||||
|
|
||||||
reducers[FETCH_CLAIM_LIST_MINE_STARTED] = state => Object.assign({}, state, {
|
reducers[FETCH_CLAIM_LIST_MINE_STARTED] = state => Object.assign({}, state, {
|
||||||
|
@ -4674,7 +4700,7 @@ reducers[ABANDON_CLAIM_SUCCEEDED] = (state, action) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
reducers[CREATE_CHANNEL_STARTED] = state => _extends$8({}, state, {
|
reducers[CREATE_CHANNEL_STARTED] = state => _extends$9({}, state, {
|
||||||
creatingChannel: true,
|
creatingChannel: true,
|
||||||
createChannelError: null
|
createChannelError: null
|
||||||
});
|
});
|
||||||
|
@ -4762,7 +4788,7 @@ reducers[CLAIM_SEARCH_COMPLETED] = (state, action) => {
|
||||||
|
|
||||||
delete fetchingClaimSearchByQuery[query];
|
delete fetchingClaimSearchByQuery[query];
|
||||||
|
|
||||||
return Object.assign({}, state, _extends$8({}, handleClaimAction(state, action), {
|
return Object.assign({}, state, _extends$9({}, handleClaimAction(state, action), {
|
||||||
claimSearchByQuery,
|
claimSearchByQuery,
|
||||||
claimSearchByQueryLastPageReached,
|
claimSearchByQueryLastPageReached,
|
||||||
fetchingClaimSearchByQuery
|
fetchingClaimSearchByQuery
|
||||||
|
@ -4802,7 +4828,7 @@ const handleActions = (actionMap, defaultState) => (state = defaultState, action
|
||||||
return state;
|
return state;
|
||||||
};
|
};
|
||||||
|
|
||||||
var _extends$9 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
var _extends$a = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
||||||
|
|
||||||
const defaultState$1 = {
|
const defaultState$1 = {
|
||||||
commentById: {}, // commentId -> Comment
|
commentById: {}, // commentId -> Comment
|
||||||
|
@ -4813,11 +4839,11 @@ const defaultState$1 = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const commentReducer = handleActions({
|
const commentReducer = handleActions({
|
||||||
[COMMENT_CREATE_STARTED]: (state, action) => _extends$9({}, state, {
|
[COMMENT_CREATE_STARTED]: (state, action) => _extends$a({}, state, {
|
||||||
isLoading: true
|
isLoading: true
|
||||||
}),
|
}),
|
||||||
|
|
||||||
[COMMENT_CREATE_FAILED]: (state, action) => _extends$9({}, state, {
|
[COMMENT_CREATE_FAILED]: (state, action) => _extends$a({}, state, {
|
||||||
isLoading: false
|
isLoading: false
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
@ -4835,14 +4861,14 @@ const commentReducer = handleActions({
|
||||||
newCommentIds.unshift(comment.comment_id);
|
newCommentIds.unshift(comment.comment_id);
|
||||||
byId[claimId] = newCommentIds;
|
byId[claimId] = newCommentIds;
|
||||||
|
|
||||||
return _extends$9({}, state, {
|
return _extends$a({}, state, {
|
||||||
commentById,
|
commentById,
|
||||||
byId,
|
byId,
|
||||||
isLoading: false
|
isLoading: false
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
[COMMENT_LIST_STARTED]: state => _extends$9({}, state, { isLoading: true }),
|
[COMMENT_LIST_STARTED]: state => _extends$a({}, state, { isLoading: true }),
|
||||||
|
|
||||||
[COMMENT_LIST_COMPLETED]: (state, action) => {
|
[COMMENT_LIST_COMPLETED]: (state, action) => {
|
||||||
const { comments, claimId, uri } = action.data;
|
const { comments, claimId, uri } = action.data;
|
||||||
|
@ -4866,7 +4892,7 @@ const commentReducer = handleActions({
|
||||||
byId[claimId] = commentIds;
|
byId[claimId] = commentIds;
|
||||||
commentsByUri[uri] = claimId;
|
commentsByUri[uri] = claimId;
|
||||||
}
|
}
|
||||||
return _extends$9({}, state, {
|
return _extends$a({}, state, {
|
||||||
byId,
|
byId,
|
||||||
commentById,
|
commentById,
|
||||||
commentsByUri,
|
commentsByUri,
|
||||||
|
@ -4874,10 +4900,10 @@ const commentReducer = handleActions({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
[COMMENT_LIST_FAILED]: (state, action) => _extends$9({}, state, {
|
[COMMENT_LIST_FAILED]: (state, action) => _extends$a({}, state, {
|
||||||
isLoading: false
|
isLoading: false
|
||||||
}),
|
}),
|
||||||
[COMMENT_ABANDON_STARTED]: (state, action) => _extends$9({}, state, {
|
[COMMENT_ABANDON_STARTED]: (state, action) => _extends$a({}, state, {
|
||||||
isLoading: true
|
isLoading: true
|
||||||
}),
|
}),
|
||||||
[COMMENT_ABANDON_COMPLETED]: (state, action) => {
|
[COMMENT_ABANDON_COMPLETED]: (state, action) => {
|
||||||
|
@ -4895,18 +4921,18 @@ const commentReducer = handleActions({
|
||||||
}
|
}
|
||||||
delete commentById[comment_id];
|
delete commentById[comment_id];
|
||||||
|
|
||||||
return _extends$9({}, state, {
|
return _extends$a({}, state, {
|
||||||
commentById,
|
commentById,
|
||||||
byId,
|
byId,
|
||||||
isLoading: false
|
isLoading: false
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
// do nothing
|
// do nothing
|
||||||
[COMMENT_ABANDON_FAILED]: (state, action) => _extends$9({}, state, {
|
[COMMENT_ABANDON_FAILED]: (state, action) => _extends$a({}, state, {
|
||||||
isLoading: false
|
isLoading: false
|
||||||
}),
|
}),
|
||||||
// do nothing
|
// do nothing
|
||||||
[COMMENT_UPDATE_STARTED]: (state, action) => _extends$9({}, state, {
|
[COMMENT_UPDATE_STARTED]: (state, action) => _extends$a({}, state, {
|
||||||
isLoading: true
|
isLoading: true
|
||||||
}),
|
}),
|
||||||
// replace existing comment with comment returned here under its comment_id
|
// replace existing comment with comment returned here under its comment_id
|
||||||
|
@ -4915,29 +4941,29 @@ const commentReducer = handleActions({
|
||||||
const commentById = Object.assign({}, state.commentById);
|
const commentById = Object.assign({}, state.commentById);
|
||||||
commentById[comment.comment_id] = comment;
|
commentById[comment.comment_id] = comment;
|
||||||
|
|
||||||
return _extends$9({}, state, {
|
return _extends$a({}, state, {
|
||||||
commentById,
|
commentById,
|
||||||
isLoading: false
|
isLoading: false
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
// nothing can be done here
|
// nothing can be done here
|
||||||
[COMMENT_UPDATE_FAILED]: (state, action) => _extends$9({}, state, {
|
[COMMENT_UPDATE_FAILED]: (state, action) => _extends$a({}, state, {
|
||||||
isLoading: false
|
isLoading: false
|
||||||
}),
|
}),
|
||||||
// nothing can really be done here
|
// nothing can really be done here
|
||||||
[COMMENT_HIDE_STARTED]: (state, action) => _extends$9({}, state, {
|
[COMMENT_HIDE_STARTED]: (state, action) => _extends$a({}, state, {
|
||||||
isLoading: true
|
isLoading: true
|
||||||
}),
|
}),
|
||||||
[COMMENT_HIDE_COMPLETED]: (state, action) => _extends$9({}, state, { // todo: add HiddenComments state & create selectors
|
[COMMENT_HIDE_COMPLETED]: (state, action) => _extends$a({}, state, { // todo: add HiddenComments state & create selectors
|
||||||
isLoading: false
|
isLoading: false
|
||||||
}),
|
}),
|
||||||
// nothing can be done here
|
// nothing can be done here
|
||||||
[COMMENT_HIDE_FAILED]: (state, action) => _extends$9({}, state, {
|
[COMMENT_HIDE_FAILED]: (state, action) => _extends$a({}, state, {
|
||||||
isLoading: false
|
isLoading: false
|
||||||
})
|
})
|
||||||
}, defaultState$1);
|
}, defaultState$1);
|
||||||
|
|
||||||
var _extends$a = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
var _extends$b = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
||||||
|
|
||||||
const reducers$1 = {};
|
const reducers$1 = {};
|
||||||
const defaultState$2 = {
|
const defaultState$2 = {
|
||||||
|
@ -4946,9 +4972,9 @@ const defaultState$2 = {
|
||||||
|
|
||||||
reducers$1[SET_CONTENT_POSITION] = (state, action) => {
|
reducers$1[SET_CONTENT_POSITION] = (state, action) => {
|
||||||
const { claimId, outpoint, position } = action.data;
|
const { claimId, outpoint, position } = action.data;
|
||||||
return _extends$a({}, state, {
|
return _extends$b({}, state, {
|
||||||
positions: _extends$a({}, state.positions, {
|
positions: _extends$b({}, state.positions, {
|
||||||
[claimId]: _extends$a({}, state.positions[claimId], {
|
[claimId]: _extends$b({}, state.positions[claimId], {
|
||||||
[outpoint]: position
|
[outpoint]: position
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -5115,7 +5141,7 @@ function fileInfoReducer(state = defaultState$3, action) {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
var _extends$b = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
var _extends$c = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
||||||
|
|
||||||
const reducers$3 = {};
|
const reducers$3 = {};
|
||||||
const defaultState$4 = {
|
const defaultState$4 = {
|
||||||
|
@ -5131,7 +5157,7 @@ reducers$3[PURCHASE_URI_STARTED] = (state, action) => {
|
||||||
newFailedPurchaseUris.splice(newFailedPurchaseUris.indexOf(uri), 1);
|
newFailedPurchaseUris.splice(newFailedPurchaseUris.indexOf(uri), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return _extends$b({}, state, {
|
return _extends$c({}, state, {
|
||||||
failedPurchaseUris: newFailedPurchaseUris,
|
failedPurchaseUris: newFailedPurchaseUris,
|
||||||
purchaseUriErrorMessage: ''
|
purchaseUriErrorMessage: ''
|
||||||
});
|
});
|
||||||
|
@ -5149,7 +5175,7 @@ reducers$3[PURCHASE_URI_COMPLETED] = (state, action) => {
|
||||||
newFailedPurchaseUris.splice(newFailedPurchaseUris.indexOf(uri), 1);
|
newFailedPurchaseUris.splice(newFailedPurchaseUris.indexOf(uri), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return _extends$b({}, state, {
|
return _extends$c({}, state, {
|
||||||
failedPurchaseUris: newFailedPurchaseUris,
|
failedPurchaseUris: newFailedPurchaseUris,
|
||||||
purchasedUris: newPurchasedUris,
|
purchasedUris: newPurchasedUris,
|
||||||
purchaseUriErrorMessage: ''
|
purchaseUriErrorMessage: ''
|
||||||
|
@ -5164,7 +5190,7 @@ reducers$3[PURCHASE_URI_FAILED] = (state, action) => {
|
||||||
newFailedPurchaseUris.push(uri);
|
newFailedPurchaseUris.push(uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
return _extends$b({}, state, {
|
return _extends$c({}, state, {
|
||||||
failedPurchaseUris: newFailedPurchaseUris,
|
failedPurchaseUris: newFailedPurchaseUris,
|
||||||
purchaseUriErrorMessage: error
|
purchaseUriErrorMessage: error
|
||||||
});
|
});
|
||||||
|
@ -5177,7 +5203,7 @@ reducers$3[DELETE_PURCHASED_URI] = (state, action) => {
|
||||||
newPurchasedUris.splice(newPurchasedUris.indexOf(uri), 1);
|
newPurchasedUris.splice(newPurchasedUris.indexOf(uri), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return _extends$b({}, state, {
|
return _extends$c({}, state, {
|
||||||
purchasedUris: newPurchasedUris
|
purchasedUris: newPurchasedUris
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -5188,7 +5214,7 @@ function fileReducer(state = defaultState$4, action) {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
var _extends$c = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
var _extends$d = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
||||||
|
|
||||||
const defaultState$5 = {
|
const defaultState$5 = {
|
||||||
notifications: [],
|
notifications: [],
|
||||||
|
@ -5203,7 +5229,7 @@ const notificationsReducer = handleActions({
|
||||||
const newToasts = state.toasts.slice();
|
const newToasts = state.toasts.slice();
|
||||||
newToasts.push(toast);
|
newToasts.push(toast);
|
||||||
|
|
||||||
return _extends$c({}, state, {
|
return _extends$d({}, state, {
|
||||||
toasts: newToasts
|
toasts: newToasts
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -5211,7 +5237,7 @@ const notificationsReducer = handleActions({
|
||||||
const newToasts = state.toasts.slice();
|
const newToasts = state.toasts.slice();
|
||||||
newToasts.shift();
|
newToasts.shift();
|
||||||
|
|
||||||
return _extends$c({}, state, {
|
return _extends$d({}, state, {
|
||||||
toasts: newToasts
|
toasts: newToasts
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -5222,7 +5248,7 @@ const notificationsReducer = handleActions({
|
||||||
const newNotifications = state.notifications.slice();
|
const newNotifications = state.notifications.slice();
|
||||||
newNotifications.push(notification);
|
newNotifications.push(notification);
|
||||||
|
|
||||||
return _extends$c({}, state, {
|
return _extends$d({}, state, {
|
||||||
notifications: newNotifications
|
notifications: newNotifications
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -5233,7 +5259,7 @@ const notificationsReducer = handleActions({
|
||||||
|
|
||||||
notifications = notifications.map(pastNotification => pastNotification.id === notification.id ? notification : pastNotification);
|
notifications = notifications.map(pastNotification => pastNotification.id === notification.id ? notification : pastNotification);
|
||||||
|
|
||||||
return _extends$c({}, state, {
|
return _extends$d({}, state, {
|
||||||
notifications
|
notifications
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -5242,7 +5268,7 @@ const notificationsReducer = handleActions({
|
||||||
let newNotifications = state.notifications.slice();
|
let newNotifications = state.notifications.slice();
|
||||||
newNotifications = newNotifications.filter(notification => notification.id !== id);
|
newNotifications = newNotifications.filter(notification => notification.id !== id);
|
||||||
|
|
||||||
return _extends$c({}, state, {
|
return _extends$d({}, state, {
|
||||||
notifications: newNotifications
|
notifications: newNotifications
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -5253,7 +5279,7 @@ const notificationsReducer = handleActions({
|
||||||
const newErrors = state.errors.slice();
|
const newErrors = state.errors.slice();
|
||||||
newErrors.push(error);
|
newErrors.push(error);
|
||||||
|
|
||||||
return _extends$c({}, state, {
|
return _extends$d({}, state, {
|
||||||
errors: newErrors
|
errors: newErrors
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -5261,13 +5287,13 @@ const notificationsReducer = handleActions({
|
||||||
const newErrors = state.errors.slice();
|
const newErrors = state.errors.slice();
|
||||||
newErrors.shift();
|
newErrors.shift();
|
||||||
|
|
||||||
return _extends$c({}, state, {
|
return _extends$d({}, state, {
|
||||||
errors: newErrors
|
errors: newErrors
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, defaultState$5);
|
}, defaultState$5);
|
||||||
|
|
||||||
var _extends$d = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
var _extends$e = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
||||||
|
|
||||||
function _objectWithoutProperties$3(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
|
function _objectWithoutProperties$3(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
|
||||||
|
|
||||||
|
@ -5304,17 +5330,17 @@ const defaultState$6 = {
|
||||||
const publishReducer = handleActions({
|
const publishReducer = handleActions({
|
||||||
[UPDATE_PUBLISH_FORM]: (state, action) => {
|
[UPDATE_PUBLISH_FORM]: (state, action) => {
|
||||||
const { data } = action;
|
const { data } = action;
|
||||||
return _extends$d({}, state, data);
|
return _extends$e({}, state, data);
|
||||||
},
|
},
|
||||||
[CLEAR_PUBLISH]: () => _extends$d({}, defaultState$6),
|
[CLEAR_PUBLISH]: () => _extends$e({}, defaultState$6),
|
||||||
[PUBLISH_START]: state => _extends$d({}, state, {
|
[PUBLISH_START]: state => _extends$e({}, state, {
|
||||||
publishing: true,
|
publishing: true,
|
||||||
publishSuccess: false
|
publishSuccess: false
|
||||||
}),
|
}),
|
||||||
[PUBLISH_FAIL]: state => _extends$d({}, state, {
|
[PUBLISH_FAIL]: state => _extends$e({}, state, {
|
||||||
publishing: false
|
publishing: false
|
||||||
}),
|
}),
|
||||||
[PUBLISH_SUCCESS]: state => _extends$d({}, state, {
|
[PUBLISH_SUCCESS]: state => _extends$e({}, state, {
|
||||||
publishing: false,
|
publishing: false,
|
||||||
publishSuccess: true
|
publishSuccess: true
|
||||||
}),
|
}),
|
||||||
|
@ -5329,14 +5355,14 @@ const publishReducer = handleActions({
|
||||||
streamName: name
|
streamName: name
|
||||||
});
|
});
|
||||||
|
|
||||||
return _extends$d({}, defaultState$6, publishData, {
|
return _extends$e({}, defaultState$6, publishData, {
|
||||||
editingURI: uri,
|
editingURI: uri,
|
||||||
uri: shortUri
|
uri: shortUri
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, defaultState$6);
|
}, defaultState$6);
|
||||||
|
|
||||||
var _extends$e = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
var _extends$f = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
||||||
|
|
||||||
const defaultState$7 = {
|
const defaultState$7 = {
|
||||||
isActive: false, // does the user have any typed text in the search input
|
isActive: false, // does the user have any typed text in the search input
|
||||||
|
@ -5358,23 +5384,23 @@ const defaultState$7 = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const searchReducer = handleActions({
|
const searchReducer = handleActions({
|
||||||
[SEARCH_START]: state => _extends$e({}, state, {
|
[SEARCH_START]: state => _extends$f({}, state, {
|
||||||
searching: true
|
searching: true
|
||||||
}),
|
}),
|
||||||
[SEARCH_SUCCESS]: (state, action) => {
|
[SEARCH_SUCCESS]: (state, action) => {
|
||||||
const { query, uris } = action.data;
|
const { query, uris } = action.data;
|
||||||
|
|
||||||
return _extends$e({}, state, {
|
return _extends$f({}, state, {
|
||||||
searching: false,
|
searching: false,
|
||||||
urisByQuery: Object.assign({}, state.urisByQuery, { [query]: uris })
|
urisByQuery: Object.assign({}, state.urisByQuery, { [query]: uris })
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
[SEARCH_FAIL]: state => _extends$e({}, state, {
|
[SEARCH_FAIL]: state => _extends$f({}, state, {
|
||||||
searching: false
|
searching: false
|
||||||
}),
|
}),
|
||||||
|
|
||||||
[RESOLVED_SEARCH_START]: state => _extends$e({}, state, {
|
[RESOLVED_SEARCH_START]: state => _extends$f({}, state, {
|
||||||
searching: true
|
searching: true
|
||||||
}),
|
}),
|
||||||
[RESOLVED_SEARCH_SUCCESS]: (state, action) => {
|
[RESOLVED_SEARCH_SUCCESS]: (state, action) => {
|
||||||
|
@ -5392,24 +5418,24 @@ const searchReducer = handleActions({
|
||||||
// the returned number of urls is less than the page size, so we're on the last page
|
// the returned number of urls is less than the page size, so we're on the last page
|
||||||
resolvedResultsByQueryLastPageReached[query] = results.length < pageSize;
|
resolvedResultsByQueryLastPageReached[query] = results.length < pageSize;
|
||||||
|
|
||||||
return _extends$e({}, state, {
|
return _extends$f({}, state, {
|
||||||
searching: false,
|
searching: false,
|
||||||
resolvedResultsByQuery,
|
resolvedResultsByQuery,
|
||||||
resolvedResultsByQueryLastPageReached
|
resolvedResultsByQueryLastPageReached
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
[RESOLVED_SEARCH_FAIL]: state => _extends$e({}, state, {
|
[RESOLVED_SEARCH_FAIL]: state => _extends$f({}, state, {
|
||||||
searching: false
|
searching: false
|
||||||
}),
|
}),
|
||||||
|
|
||||||
[UPDATE_SEARCH_QUERY]: (state, action) => _extends$e({}, state, {
|
[UPDATE_SEARCH_QUERY]: (state, action) => _extends$f({}, state, {
|
||||||
searchQuery: action.data.query,
|
searchQuery: action.data.query,
|
||||||
isActive: true
|
isActive: true
|
||||||
}),
|
}),
|
||||||
|
|
||||||
[UPDATE_SEARCH_SUGGESTIONS]: (state, action) => _extends$e({}, state, {
|
[UPDATE_SEARCH_SUGGESTIONS]: (state, action) => _extends$f({}, state, {
|
||||||
suggestions: _extends$e({}, state.suggestions, {
|
suggestions: _extends$f({}, state.suggestions, {
|
||||||
[action.data.query]: action.data.suggestions
|
[action.data.query]: action.data.suggestions
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
|
@ -5417,30 +5443,30 @@ const searchReducer = handleActions({
|
||||||
// sets isActive to false so the uri will be populated correctly if the
|
// sets isActive to false so the uri will be populated correctly if the
|
||||||
// user is on a file page. The search query will still be present on any
|
// user is on a file page. The search query will still be present on any
|
||||||
// other page
|
// other page
|
||||||
[DISMISS_NOTIFICATION]: state => _extends$e({}, state, {
|
[DISMISS_NOTIFICATION]: state => _extends$f({}, state, {
|
||||||
isActive: false
|
isActive: false
|
||||||
}),
|
}),
|
||||||
|
|
||||||
[SEARCH_FOCUS]: state => _extends$e({}, state, {
|
[SEARCH_FOCUS]: state => _extends$f({}, state, {
|
||||||
focused: true
|
focused: true
|
||||||
}),
|
}),
|
||||||
[SEARCH_BLUR]: state => _extends$e({}, state, {
|
[SEARCH_BLUR]: state => _extends$f({}, state, {
|
||||||
focused: false
|
focused: false
|
||||||
}),
|
}),
|
||||||
[UPDATE_SEARCH_OPTIONS]: (state, action) => {
|
[UPDATE_SEARCH_OPTIONS]: (state, action) => {
|
||||||
const { options: oldOptions } = state;
|
const { options: oldOptions } = state;
|
||||||
const newOptions = action.data;
|
const newOptions = action.data;
|
||||||
const options = _extends$e({}, oldOptions, newOptions);
|
const options = _extends$f({}, oldOptions, newOptions);
|
||||||
return _extends$e({}, state, {
|
return _extends$f({}, state, {
|
||||||
options
|
options
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, defaultState$7);
|
}, defaultState$7);
|
||||||
|
|
||||||
var _extends$f = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
var _extends$g = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
||||||
|
|
||||||
function getDefaultKnownTags() {
|
function getDefaultKnownTags() {
|
||||||
return DEFAULT_FOLLOWED_TAGS.concat(DEFAULT_KNOWN_TAGS).reduce((tagsMap, tag) => _extends$f({}, tagsMap, {
|
return DEFAULT_FOLLOWED_TAGS.concat(DEFAULT_KNOWN_TAGS).reduce((tagsMap, tag) => _extends$g({}, tagsMap, {
|
||||||
[tag]: { name: tag }
|
[tag]: { name: tag }
|
||||||
}), {});
|
}), {});
|
||||||
}
|
}
|
||||||
|
@ -5463,7 +5489,7 @@ const tagsReducer = handleActions({
|
||||||
newFollowedTags.push(name);
|
newFollowedTags.push(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return _extends$f({}, state, {
|
return _extends$g({}, state, {
|
||||||
followedTags: newFollowedTags
|
followedTags: newFollowedTags
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -5472,10 +5498,10 @@ const tagsReducer = handleActions({
|
||||||
const { knownTags } = state;
|
const { knownTags } = state;
|
||||||
const { name } = action.data;
|
const { name } = action.data;
|
||||||
|
|
||||||
let newKnownTags = _extends$f({}, knownTags);
|
let newKnownTags = _extends$g({}, knownTags);
|
||||||
newKnownTags[name] = { name };
|
newKnownTags[name] = { name };
|
||||||
|
|
||||||
return _extends$f({}, state, {
|
return _extends$g({}, state, {
|
||||||
knownTags: newKnownTags
|
knownTags: newKnownTags
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -5484,24 +5510,24 @@ const tagsReducer = handleActions({
|
||||||
const { knownTags, followedTags } = state;
|
const { knownTags, followedTags } = state;
|
||||||
const { name } = action.data;
|
const { name } = action.data;
|
||||||
|
|
||||||
let newKnownTags = _extends$f({}, knownTags);
|
let newKnownTags = _extends$g({}, knownTags);
|
||||||
delete newKnownTags[name];
|
delete newKnownTags[name];
|
||||||
const newFollowedTags = followedTags.filter(tag => tag !== name);
|
const newFollowedTags = followedTags.filter(tag => tag !== name);
|
||||||
|
|
||||||
return _extends$f({}, state, {
|
return _extends$g({}, state, {
|
||||||
knownTags: newKnownTags,
|
knownTags: newKnownTags,
|
||||||
followedTags: newFollowedTags
|
followedTags: newFollowedTags
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
[USER_STATE_POPULATE]: (state, action) => {
|
[USER_STATE_POPULATE]: (state, action) => {
|
||||||
const { tags } = action.data;
|
const { tags } = action.data;
|
||||||
return _extends$f({}, state, {
|
return _extends$g({}, state, {
|
||||||
followedTags: tags && tags.length ? tags : DEFAULT_FOLLOWED_TAGS
|
followedTags: tags && tags.length ? tags : DEFAULT_FOLLOWED_TAGS
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, defaultState$8);
|
}, defaultState$8);
|
||||||
|
|
||||||
var _extends$g = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
var _extends$h = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
||||||
|
|
||||||
const defaultState$9 = {
|
const defaultState$9 = {
|
||||||
blockedChannels: []
|
blockedChannels: []
|
||||||
|
@ -5525,13 +5551,13 @@ const blockedReducer = handleActions({
|
||||||
},
|
},
|
||||||
[USER_STATE_POPULATE]: (state, action) => {
|
[USER_STATE_POPULATE]: (state, action) => {
|
||||||
const { blocked } = action.data;
|
const { blocked } = action.data;
|
||||||
return _extends$g({}, state, {
|
return _extends$h({}, state, {
|
||||||
blockedChannels: blocked && blocked.length ? blocked : state.blockedChannels
|
blockedChannels: blocked && blocked.length ? blocked : state.blockedChannels
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, defaultState$9);
|
}, defaultState$9);
|
||||||
|
|
||||||
var _extends$h = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
var _extends$i = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
||||||
|
|
||||||
const buildDraftTransaction = () => ({
|
const buildDraftTransaction = () => ({
|
||||||
amount: undefined,
|
amount: undefined,
|
||||||
|
@ -5576,25 +5602,25 @@ const defaultState$a = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const walletReducer = handleActions({
|
const walletReducer = handleActions({
|
||||||
[FETCH_TRANSACTIONS_STARTED]: state => _extends$h({}, state, {
|
[FETCH_TRANSACTIONS_STARTED]: state => _extends$i({}, state, {
|
||||||
fetchingTransactions: true
|
fetchingTransactions: true
|
||||||
}),
|
}),
|
||||||
|
|
||||||
[FETCH_TRANSACTIONS_COMPLETED]: (state, action) => {
|
[FETCH_TRANSACTIONS_COMPLETED]: (state, action) => {
|
||||||
const byId = _extends$h({}, state.transactions);
|
const byId = _extends$i({}, state.transactions);
|
||||||
|
|
||||||
const { transactions } = action.data;
|
const { transactions } = action.data;
|
||||||
transactions.forEach(transaction => {
|
transactions.forEach(transaction => {
|
||||||
byId[transaction.txid] = transaction;
|
byId[transaction.txid] = transaction;
|
||||||
});
|
});
|
||||||
|
|
||||||
return _extends$h({}, state, {
|
return _extends$i({}, state, {
|
||||||
transactions: byId,
|
transactions: byId,
|
||||||
fetchingTransactions: false
|
fetchingTransactions: false
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
[FETCH_SUPPORTS_STARTED]: state => _extends$h({}, state, {
|
[FETCH_SUPPORTS_STARTED]: state => _extends$i({}, state, {
|
||||||
fetchingSupports: true
|
fetchingSupports: true
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
@ -5607,7 +5633,7 @@ const walletReducer = handleActions({
|
||||||
byOutpoint[`${txid}:${nout}`] = transaction;
|
byOutpoint[`${txid}:${nout}`] = transaction;
|
||||||
});
|
});
|
||||||
|
|
||||||
return _extends$h({}, state, { supports: byOutpoint, fetchingSupports: false });
|
return _extends$i({}, state, { supports: byOutpoint, fetchingSupports: false });
|
||||||
},
|
},
|
||||||
|
|
||||||
[ABANDON_SUPPORT_STARTED]: (state, action) => {
|
[ABANDON_SUPPORT_STARTED]: (state, action) => {
|
||||||
|
@ -5616,7 +5642,7 @@ const walletReducer = handleActions({
|
||||||
|
|
||||||
currentlyAbandoning[outpoint] = true;
|
currentlyAbandoning[outpoint] = true;
|
||||||
|
|
||||||
return _extends$h({}, state, {
|
return _extends$i({}, state, {
|
||||||
abandoningSupportsByOutpoint: currentlyAbandoning
|
abandoningSupportsByOutpoint: currentlyAbandoning
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -5629,23 +5655,23 @@ const walletReducer = handleActions({
|
||||||
delete currentlyAbandoning[outpoint];
|
delete currentlyAbandoning[outpoint];
|
||||||
delete byOutpoint[outpoint];
|
delete byOutpoint[outpoint];
|
||||||
|
|
||||||
return _extends$h({}, state, {
|
return _extends$i({}, state, {
|
||||||
supports: byOutpoint,
|
supports: byOutpoint,
|
||||||
abandoningSupportsById: currentlyAbandoning
|
abandoningSupportsById: currentlyAbandoning
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
[GET_NEW_ADDRESS_STARTED]: state => _extends$h({}, state, {
|
[GET_NEW_ADDRESS_STARTED]: state => _extends$i({}, state, {
|
||||||
gettingNewAddress: true
|
gettingNewAddress: true
|
||||||
}),
|
}),
|
||||||
|
|
||||||
[GET_NEW_ADDRESS_COMPLETED]: (state, action) => {
|
[GET_NEW_ADDRESS_COMPLETED]: (state, action) => {
|
||||||
const { address } = action.data;
|
const { address } = action.data;
|
||||||
|
|
||||||
return _extends$h({}, state, { gettingNewAddress: false, receiveAddress: address });
|
return _extends$i({}, state, { gettingNewAddress: false, receiveAddress: address });
|
||||||
},
|
},
|
||||||
|
|
||||||
[UPDATE_BALANCE]: (state, action) => _extends$h({}, state, {
|
[UPDATE_BALANCE]: (state, action) => _extends$i({}, state, {
|
||||||
totalBalance: action.data.totalBalance,
|
totalBalance: action.data.totalBalance,
|
||||||
balance: action.data.balance,
|
balance: action.data.balance,
|
||||||
reservedBalance: action.data.reservedBalance,
|
reservedBalance: action.data.reservedBalance,
|
||||||
|
@ -5654,32 +5680,32 @@ const walletReducer = handleActions({
|
||||||
tipsBalance: action.data.tipsBalance
|
tipsBalance: action.data.tipsBalance
|
||||||
}),
|
}),
|
||||||
|
|
||||||
[CHECK_ADDRESS_IS_MINE_STARTED]: state => _extends$h({}, state, {
|
[CHECK_ADDRESS_IS_MINE_STARTED]: state => _extends$i({}, state, {
|
||||||
checkingAddressOwnership: true
|
checkingAddressOwnership: true
|
||||||
}),
|
}),
|
||||||
|
|
||||||
[CHECK_ADDRESS_IS_MINE_COMPLETED]: state => _extends$h({}, state, {
|
[CHECK_ADDRESS_IS_MINE_COMPLETED]: state => _extends$i({}, state, {
|
||||||
checkingAddressOwnership: false
|
checkingAddressOwnership: false
|
||||||
}),
|
}),
|
||||||
|
|
||||||
[SET_DRAFT_TRANSACTION_AMOUNT]: (state, action) => {
|
[SET_DRAFT_TRANSACTION_AMOUNT]: (state, action) => {
|
||||||
const oldDraft = state.draftTransaction;
|
const oldDraft = state.draftTransaction;
|
||||||
const newDraft = _extends$h({}, oldDraft, { amount: parseFloat(action.data.amount) });
|
const newDraft = _extends$i({}, oldDraft, { amount: parseFloat(action.data.amount) });
|
||||||
|
|
||||||
return _extends$h({}, state, { draftTransaction: newDraft });
|
return _extends$i({}, state, { draftTransaction: newDraft });
|
||||||
},
|
},
|
||||||
|
|
||||||
[SET_DRAFT_TRANSACTION_ADDRESS]: (state, action) => {
|
[SET_DRAFT_TRANSACTION_ADDRESS]: (state, action) => {
|
||||||
const oldDraft = state.draftTransaction;
|
const oldDraft = state.draftTransaction;
|
||||||
const newDraft = _extends$h({}, oldDraft, { address: action.data.address });
|
const newDraft = _extends$i({}, oldDraft, { address: action.data.address });
|
||||||
|
|
||||||
return _extends$h({}, state, { draftTransaction: newDraft });
|
return _extends$i({}, state, { draftTransaction: newDraft });
|
||||||
},
|
},
|
||||||
|
|
||||||
[SEND_TRANSACTION_STARTED]: state => {
|
[SEND_TRANSACTION_STARTED]: state => {
|
||||||
const newDraftTransaction = _extends$h({}, state.draftTransaction, { sending: true });
|
const newDraftTransaction = _extends$i({}, state.draftTransaction, { sending: true });
|
||||||
|
|
||||||
return _extends$h({}, state, { draftTransaction: newDraftTransaction });
|
return _extends$i({}, state, { draftTransaction: newDraftTransaction });
|
||||||
},
|
},
|
||||||
|
|
||||||
[SEND_TRANSACTION_COMPLETED]: state => Object.assign({}, state, {
|
[SEND_TRANSACTION_COMPLETED]: state => Object.assign({}, state, {
|
||||||
|
@ -5692,114 +5718,114 @@ const walletReducer = handleActions({
|
||||||
error: action.data.error
|
error: action.data.error
|
||||||
});
|
});
|
||||||
|
|
||||||
return _extends$h({}, state, { draftTransaction: newDraftTransaction });
|
return _extends$i({}, state, { draftTransaction: newDraftTransaction });
|
||||||
},
|
},
|
||||||
|
|
||||||
[SUPPORT_TRANSACTION_STARTED]: state => _extends$h({}, state, {
|
[SUPPORT_TRANSACTION_STARTED]: state => _extends$i({}, state, {
|
||||||
sendingSupport: true
|
sendingSupport: true
|
||||||
}),
|
}),
|
||||||
|
|
||||||
[SUPPORT_TRANSACTION_COMPLETED]: state => _extends$h({}, state, {
|
[SUPPORT_TRANSACTION_COMPLETED]: state => _extends$i({}, state, {
|
||||||
sendingSupport: false
|
sendingSupport: false
|
||||||
}),
|
}),
|
||||||
|
|
||||||
[SUPPORT_TRANSACTION_FAILED]: (state, action) => _extends$h({}, state, {
|
[SUPPORT_TRANSACTION_FAILED]: (state, action) => _extends$i({}, state, {
|
||||||
error: action.data.error,
|
error: action.data.error,
|
||||||
sendingSupport: false
|
sendingSupport: false
|
||||||
}),
|
}),
|
||||||
|
|
||||||
[CLEAR_SUPPORT_TRANSACTION]: state => _extends$h({}, state, {
|
[CLEAR_SUPPORT_TRANSACTION]: state => _extends$i({}, state, {
|
||||||
sendingSupport: false
|
sendingSupport: false
|
||||||
}),
|
}),
|
||||||
|
|
||||||
[WALLET_STATUS_COMPLETED]: (state, action) => _extends$h({}, state, {
|
[WALLET_STATUS_COMPLETED]: (state, action) => _extends$i({}, state, {
|
||||||
walletIsEncrypted: action.result
|
walletIsEncrypted: action.result
|
||||||
}),
|
}),
|
||||||
|
|
||||||
[WALLET_ENCRYPT_START]: state => _extends$h({}, state, {
|
[WALLET_ENCRYPT_START]: state => _extends$i({}, state, {
|
||||||
walletEncryptPending: true,
|
walletEncryptPending: true,
|
||||||
walletEncryptSucceded: null,
|
walletEncryptSucceded: null,
|
||||||
walletEncryptResult: null
|
walletEncryptResult: null
|
||||||
}),
|
}),
|
||||||
|
|
||||||
[WALLET_ENCRYPT_COMPLETED]: (state, action) => _extends$h({}, state, {
|
[WALLET_ENCRYPT_COMPLETED]: (state, action) => _extends$i({}, state, {
|
||||||
walletEncryptPending: false,
|
walletEncryptPending: false,
|
||||||
walletEncryptSucceded: true,
|
walletEncryptSucceded: true,
|
||||||
walletEncryptResult: action.result
|
walletEncryptResult: action.result
|
||||||
}),
|
}),
|
||||||
|
|
||||||
[WALLET_ENCRYPT_FAILED]: (state, action) => _extends$h({}, state, {
|
[WALLET_ENCRYPT_FAILED]: (state, action) => _extends$i({}, state, {
|
||||||
walletEncryptPending: false,
|
walletEncryptPending: false,
|
||||||
walletEncryptSucceded: false,
|
walletEncryptSucceded: false,
|
||||||
walletEncryptResult: action.result
|
walletEncryptResult: action.result
|
||||||
}),
|
}),
|
||||||
|
|
||||||
[WALLET_DECRYPT_START]: state => _extends$h({}, state, {
|
[WALLET_DECRYPT_START]: state => _extends$i({}, state, {
|
||||||
walletDecryptPending: true,
|
walletDecryptPending: true,
|
||||||
walletDecryptSucceded: null,
|
walletDecryptSucceded: null,
|
||||||
walletDecryptResult: null
|
walletDecryptResult: null
|
||||||
}),
|
}),
|
||||||
|
|
||||||
[WALLET_DECRYPT_COMPLETED]: (state, action) => _extends$h({}, state, {
|
[WALLET_DECRYPT_COMPLETED]: (state, action) => _extends$i({}, state, {
|
||||||
walletDecryptPending: false,
|
walletDecryptPending: false,
|
||||||
walletDecryptSucceded: true,
|
walletDecryptSucceded: true,
|
||||||
walletDecryptResult: action.result
|
walletDecryptResult: action.result
|
||||||
}),
|
}),
|
||||||
|
|
||||||
[WALLET_DECRYPT_FAILED]: (state, action) => _extends$h({}, state, {
|
[WALLET_DECRYPT_FAILED]: (state, action) => _extends$i({}, state, {
|
||||||
walletDecryptPending: false,
|
walletDecryptPending: false,
|
||||||
walletDecryptSucceded: false,
|
walletDecryptSucceded: false,
|
||||||
walletDecryptResult: action.result
|
walletDecryptResult: action.result
|
||||||
}),
|
}),
|
||||||
|
|
||||||
[WALLET_UNLOCK_START]: state => _extends$h({}, state, {
|
[WALLET_UNLOCK_START]: state => _extends$i({}, state, {
|
||||||
walletUnlockPending: true,
|
walletUnlockPending: true,
|
||||||
walletUnlockSucceded: null,
|
walletUnlockSucceded: null,
|
||||||
walletUnlockResult: null
|
walletUnlockResult: null
|
||||||
}),
|
}),
|
||||||
|
|
||||||
[WALLET_UNLOCK_COMPLETED]: (state, action) => _extends$h({}, state, {
|
[WALLET_UNLOCK_COMPLETED]: (state, action) => _extends$i({}, state, {
|
||||||
walletUnlockPending: false,
|
walletUnlockPending: false,
|
||||||
walletUnlockSucceded: true,
|
walletUnlockSucceded: true,
|
||||||
walletUnlockResult: action.result
|
walletUnlockResult: action.result
|
||||||
}),
|
}),
|
||||||
|
|
||||||
[WALLET_UNLOCK_FAILED]: (state, action) => _extends$h({}, state, {
|
[WALLET_UNLOCK_FAILED]: (state, action) => _extends$i({}, state, {
|
||||||
walletUnlockPending: false,
|
walletUnlockPending: false,
|
||||||
walletUnlockSucceded: false,
|
walletUnlockSucceded: false,
|
||||||
walletUnlockResult: action.result
|
walletUnlockResult: action.result
|
||||||
}),
|
}),
|
||||||
|
|
||||||
[WALLET_LOCK_START]: state => _extends$h({}, state, {
|
[WALLET_LOCK_START]: state => _extends$i({}, state, {
|
||||||
walletLockPending: false,
|
walletLockPending: false,
|
||||||
walletLockSucceded: null,
|
walletLockSucceded: null,
|
||||||
walletLockResult: null
|
walletLockResult: null
|
||||||
}),
|
}),
|
||||||
|
|
||||||
[WALLET_LOCK_COMPLETED]: (state, action) => _extends$h({}, state, {
|
[WALLET_LOCK_COMPLETED]: (state, action) => _extends$i({}, state, {
|
||||||
walletLockPending: false,
|
walletLockPending: false,
|
||||||
walletLockSucceded: true,
|
walletLockSucceded: true,
|
||||||
walletLockResult: action.result
|
walletLockResult: action.result
|
||||||
}),
|
}),
|
||||||
|
|
||||||
[WALLET_LOCK_FAILED]: (state, action) => _extends$h({}, state, {
|
[WALLET_LOCK_FAILED]: (state, action) => _extends$i({}, state, {
|
||||||
walletLockPending: false,
|
walletLockPending: false,
|
||||||
walletLockSucceded: false,
|
walletLockSucceded: false,
|
||||||
walletLockResult: action.result
|
walletLockResult: action.result
|
||||||
}),
|
}),
|
||||||
|
|
||||||
[SET_TRANSACTION_LIST_FILTER]: (state, action) => _extends$h({}, state, {
|
[SET_TRANSACTION_LIST_FILTER]: (state, action) => _extends$i({}, state, {
|
||||||
transactionListFilter: action.data
|
transactionListFilter: action.data
|
||||||
}),
|
}),
|
||||||
|
|
||||||
[UPDATE_CURRENT_HEIGHT]: (state, action) => _extends$h({}, state, {
|
[UPDATE_CURRENT_HEIGHT]: (state, action) => _extends$i({}, state, {
|
||||||
latestBlock: action.data
|
latestBlock: action.data
|
||||||
}),
|
}),
|
||||||
[WALLET_RESTART]: state => _extends$h({}, state, {
|
[WALLET_RESTART]: state => _extends$i({}, state, {
|
||||||
walletReconnecting: true
|
walletReconnecting: true
|
||||||
}),
|
}),
|
||||||
|
|
||||||
[WALLET_RESTART_COMPLETED]: state => _extends$h({}, state, {
|
[WALLET_RESTART_COMPLETED]: state => _extends$i({}, state, {
|
||||||
walletReconnecting: false
|
walletReconnecting: false
|
||||||
})
|
})
|
||||||
}, defaultState$a);
|
}, defaultState$a);
|
||||||
|
@ -5817,14 +5843,14 @@ const makeSelectContentPositionForUri = uri => reselect.createSelector(selectSta
|
||||||
return state.positions[id] ? state.positions[id][outpoint] : null;
|
return state.positions[id] ? state.positions[id][outpoint] : null;
|
||||||
});
|
});
|
||||||
|
|
||||||
var _extends$i = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
var _extends$j = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
||||||
|
|
||||||
const selectState$7 = state => state.notifications || {};
|
const selectState$7 = state => state.notifications || {};
|
||||||
|
|
||||||
const selectToast = reselect.createSelector(selectState$7, state => {
|
const selectToast = reselect.createSelector(selectState$7, state => {
|
||||||
if (state.toasts.length) {
|
if (state.toasts.length) {
|
||||||
const { id, params } = state.toasts[0];
|
const { id, params } = state.toasts[0];
|
||||||
return _extends$i({
|
return _extends$j({
|
||||||
id
|
id
|
||||||
}, params);
|
}, params);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,15 @@ const DEBOUNCED_SEARCH_SUGGESTION_MS = 300;
|
||||||
type Dispatch = (action: any) => any;
|
type Dispatch = (action: any) => any;
|
||||||
type GetState = () => { search: SearchState };
|
type GetState = () => { search: SearchState };
|
||||||
|
|
||||||
|
type SearchOptions = {
|
||||||
|
size?: number,
|
||||||
|
from?: number,
|
||||||
|
related_to?: string,
|
||||||
|
nsfw?: boolean,
|
||||||
|
isBackgroundSearch?: boolean,
|
||||||
|
resolveResults?: boolean,
|
||||||
|
};
|
||||||
|
|
||||||
// We can't use env's because they aren't passed into node_modules
|
// We can't use env's because they aren't passed into node_modules
|
||||||
let CONNECTION_STRING = 'https://lighthouse.lbry.com/';
|
let CONNECTION_STRING = 'https://lighthouse.lbry.com/';
|
||||||
|
|
||||||
|
@ -75,17 +84,13 @@ export const doUpdateSearchQuery = (query: string, shouldSkipSuggestions: ?boole
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const doSearch = (
|
export const doSearch = (rawQuery: string, searchOptions: SearchOptions) => (
|
||||||
rawQuery: string,
|
dispatch: Dispatch,
|
||||||
size: ?number, // only pass in if you don't want to use the users setting (ex: related content)
|
getState: GetState
|
||||||
from: ?number,
|
) => {
|
||||||
isBackgroundSearch: boolean = false,
|
|
||||||
options: {
|
|
||||||
related_to?: string,
|
|
||||||
} = {},
|
|
||||||
resolveResults: boolean = true
|
|
||||||
) => (dispatch: Dispatch, getState: GetState) => {
|
|
||||||
const query = rawQuery.replace(/^lbry:\/\//i, '').replace(/\//, ' ');
|
const query = rawQuery.replace(/^lbry:\/\//i, '').replace(/\//, ' ');
|
||||||
|
const resolveResults = searchOptions && searchOptions.resolveResults;
|
||||||
|
const isBackgroundSearch = (searchOptions && searchOptions.isBackgroundSearch) || false;
|
||||||
|
|
||||||
if (!query) {
|
if (!query) {
|
||||||
dispatch({
|
dispatch({
|
||||||
|
@ -95,9 +100,8 @@ export const doSearch = (
|
||||||
}
|
}
|
||||||
|
|
||||||
const state = getState();
|
const state = getState();
|
||||||
let queryWithOptions = makeSelectQueryWithOptions(query, size, from, isBackgroundSearch, options)(
|
|
||||||
state
|
let queryWithOptions = makeSelectQueryWithOptions(query, searchOptions)(state);
|
||||||
);
|
|
||||||
|
|
||||||
// If we have already searched for something, we don't need to do anything
|
// If we have already searched for something, we don't need to do anything
|
||||||
const urisForQuery = makeSelectSearchUris(queryWithOptions)(state);
|
const urisForQuery = makeSelectSearchUris(queryWithOptions)(state);
|
||||||
|
@ -162,11 +166,12 @@ export const doSearch = (
|
||||||
|
|
||||||
export const doResolvedSearch = (
|
export const doResolvedSearch = (
|
||||||
rawQuery: string,
|
rawQuery: string,
|
||||||
size: ?number, // only pass in if you don't want to use the users setting (ex: related content)
|
size?: number, // only pass in if you don't want to use the users setting (ex: related content)
|
||||||
from: ?number,
|
from?: number,
|
||||||
isBackgroundSearch: boolean = false,
|
isBackgroundSearch?: boolean = false,
|
||||||
options: {
|
options: {
|
||||||
related_to?: string,
|
related_to?: string,
|
||||||
|
// nsfw here
|
||||||
} = {}
|
} = {}
|
||||||
) => (dispatch: Dispatch, getState: GetState) => {
|
) => (dispatch: Dispatch, getState: GetState) => {
|
||||||
const query = rawQuery.replace(/^lbry:\/\//i, '').replace(/\//, ' ');
|
const query = rawQuery.replace(/^lbry:\/\//i, '').replace(/\//, ' ');
|
||||||
|
@ -178,15 +183,25 @@ export const doResolvedSearch = (
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const optionsWithFrom: SearchOptions = {
|
||||||
|
size,
|
||||||
|
from,
|
||||||
|
isBackgroundSearch,
|
||||||
|
...options,
|
||||||
|
};
|
||||||
|
|
||||||
|
const optionsWithoutFrom: SearchOptions = {
|
||||||
|
size,
|
||||||
|
isBackgroundSearch,
|
||||||
|
...options,
|
||||||
|
};
|
||||||
|
|
||||||
const state = getState();
|
const state = getState();
|
||||||
let queryWithOptions = makeSelectQueryWithOptions(query, size, from, isBackgroundSearch, options)(
|
|
||||||
state
|
let queryWithOptions = makeSelectQueryWithOptions(query, optionsWithFrom)(state);
|
||||||
);
|
|
||||||
|
|
||||||
// make from null so that we can maintain a reference to the same query for multiple pages and simply append the found results
|
// make from null so that we can maintain a reference to the same query for multiple pages and simply append the found results
|
||||||
let queryWithoutFrom = makeSelectQueryWithOptions(query, size, null, isBackgroundSearch, options)(
|
let queryWithoutFrom = makeSelectQueryWithOptions(query, optionsWithoutFrom)(state);
|
||||||
state
|
|
||||||
);
|
|
||||||
|
|
||||||
// If we have already searched for something, we don't need to do anything
|
// If we have already searched for something, we don't need to do anything
|
||||||
// TODO: Tweak this check for multiple page results
|
// TODO: Tweak this check for multiple page results
|
||||||
|
@ -241,10 +256,10 @@ export const doBlurSearchInput = () => (dispatch: Dispatch) =>
|
||||||
type: ACTIONS.SEARCH_BLUR,
|
type: ACTIONS.SEARCH_BLUR,
|
||||||
});
|
});
|
||||||
|
|
||||||
export const doUpdateSearchOptions = (newOptions: SearchOptions) => (
|
export const doUpdateSearchOptions = (
|
||||||
dispatch: Dispatch,
|
newOptions: SearchOptions,
|
||||||
getState: GetState
|
additionalOptions: SearchOptions
|
||||||
) => {
|
) => (dispatch: Dispatch, getState: GetState) => {
|
||||||
const state = getState();
|
const state = getState();
|
||||||
const searchValue = selectSearchValue(state);
|
const searchValue = selectSearchValue(state);
|
||||||
|
|
||||||
|
@ -255,6 +270,6 @@ export const doUpdateSearchOptions = (newOptions: SearchOptions) => (
|
||||||
|
|
||||||
if (searchValue) {
|
if (searchValue) {
|
||||||
// After updating, perform a search with the new options
|
// After updating, perform a search with the new options
|
||||||
dispatch(doSearch(searchValue));
|
dispatch(doSearch(searchValue, additionalOptions));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -279,8 +279,8 @@ export const makeSelectDateForUri = (uri: string) =>
|
||||||
(claim.value.release_time
|
(claim.value.release_time
|
||||||
? claim.value.release_time * 1000
|
? claim.value.release_time * 1000
|
||||||
: claim.meta && claim.meta.creation_timestamp
|
: claim.meta && claim.meta.creation_timestamp
|
||||||
? claim.meta.creation_timestamp * 1000
|
? claim.meta.creation_timestamp * 1000
|
||||||
: null);
|
: null);
|
||||||
if (!timestamp) {
|
if (!timestamp) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
@ -530,16 +530,16 @@ export const makeSelectRecommendedContentForUri = (uri: string) =>
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const options = { related_to: claim.claim_id };
|
const options: {
|
||||||
|
related_to?: string,
|
||||||
|
nsfw?: boolean,
|
||||||
|
isBackgroundSearch?: boolean,
|
||||||
|
} = { related_to: claim.claim_id, isBackgroundSearch: true };
|
||||||
|
|
||||||
if (!isMature) {
|
if (!isMature) {
|
||||||
options['nsfw'] = false;
|
options['nsfw'] = false;
|
||||||
}
|
}
|
||||||
const searchQuery = getSearchQueryString(
|
const searchQuery = getSearchQueryString(title.replace(/\//, ' '), options);
|
||||||
title.replace(/\//, ' '),
|
|
||||||
undefined,
|
|
||||||
undefined,
|
|
||||||
options
|
|
||||||
);
|
|
||||||
|
|
||||||
let searchUris = searchUrisByQuery[searchQuery];
|
let searchUris = searchUrisByQuery[searchQuery];
|
||||||
if (searchUris) {
|
if (searchUris) {
|
||||||
|
@ -671,7 +671,8 @@ export const makeSelectResolvedRecommendedContentForUri = (uri: string, size: nu
|
||||||
createSelector(
|
createSelector(
|
||||||
makeSelectClaimForUri(uri),
|
makeSelectClaimForUri(uri),
|
||||||
selectResolvedSearchResultsByQuery,
|
selectResolvedSearchResultsByQuery,
|
||||||
(claim, resolvedResultsByQuery) => {
|
makeSelectClaimIsNsfw(uri),
|
||||||
|
(claim, resolvedResultsByQuery, isMature) => {
|
||||||
const atVanityURI = !uri.includes('#');
|
const atVanityURI = !uri.includes('#');
|
||||||
|
|
||||||
let recommendedContent;
|
let recommendedContent;
|
||||||
|
@ -685,9 +686,16 @@ export const makeSelectResolvedRecommendedContentForUri = (uri: string, size: nu
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const searchQuery = getSearchQueryString(title.replace(/\//, ' '), { size }, undefined, {
|
const options: {
|
||||||
related_to: claim.claim_id,
|
related_to?: string,
|
||||||
});
|
nsfw?: boolean,
|
||||||
|
isBackgroundSearch?: boolean,
|
||||||
|
} = { related_to: claim.claim_id, isBackgroundSearch: true };
|
||||||
|
if (!isMature) {
|
||||||
|
options['nsfw'] = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const searchQuery = getSearchQueryString(title.replace(/\//, ' '), options);
|
||||||
|
|
||||||
let results = resolvedResultsByQuery[searchQuery];
|
let results = resolvedResultsByQuery[searchQuery];
|
||||||
if (results) {
|
if (results) {
|
||||||
|
|
|
@ -165,26 +165,27 @@ export const selectSearchSuggestions: Array<SearchSuggestion> = createSelector(
|
||||||
|
|
||||||
// Creates a query string based on the state in the search reducer
|
// Creates a query string based on the state in the search reducer
|
||||||
// Can be overrided by passing in custom sizes/from values for other areas pagination
|
// Can be overrided by passing in custom sizes/from values for other areas pagination
|
||||||
|
|
||||||
|
type CustomOptions = {
|
||||||
|
isBackgroundSearch?: boolean,
|
||||||
|
size?: number,
|
||||||
|
from?: number,
|
||||||
|
related_to?: string,
|
||||||
|
nsfw?: boolean,
|
||||||
|
}
|
||||||
|
|
||||||
export const makeSelectQueryWithOptions = (
|
export const makeSelectQueryWithOptions = (
|
||||||
customQuery: ?string,
|
customQuery: ?string,
|
||||||
customSize: ?number,
|
options: CustomOptions,
|
||||||
customFrom: ?number,
|
|
||||||
isBackgroundSearch: boolean = false, // If it's a background search, don't use the users settings
|
|
||||||
additionalOptions: {
|
|
||||||
related_to?: string,
|
|
||||||
} = {}
|
|
||||||
) =>
|
) =>
|
||||||
createSelector(
|
createSelector(
|
||||||
selectSearchValue,
|
selectSearchValue,
|
||||||
selectSearchOptions,
|
selectSearchOptions,
|
||||||
(query, options) => {
|
(query, defaultOptions) => {
|
||||||
const size = customSize || options[SEARCH_OPTIONS.RESULT_COUNT];
|
const searchOptions = { ...defaultOptions, ...options };
|
||||||
|
|
||||||
const queryString = getSearchQueryString(
|
const queryString = getSearchQueryString(
|
||||||
customQuery || query,
|
customQuery || query,
|
||||||
{ ...options, size, from: customFrom },
|
searchOptions,
|
||||||
!isBackgroundSearch,
|
|
||||||
additionalOptions
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return queryString;
|
return queryString;
|
||||||
|
|
|
@ -36,8 +36,6 @@ export function toQueryString(params: { [string]: string | number }) {
|
||||||
export const getSearchQueryString = (
|
export const getSearchQueryString = (
|
||||||
query: string,
|
query: string,
|
||||||
options: any = {},
|
options: any = {},
|
||||||
includeUserOptions: boolean = false,
|
|
||||||
additionalOptions: {} = {}
|
|
||||||
) => {
|
) => {
|
||||||
const encodedQuery = encodeURIComponent(query);
|
const encodedQuery = encodeURIComponent(query);
|
||||||
const queryParams = [
|
const queryParams = [
|
||||||
|
@ -45,6 +43,8 @@ export const getSearchQueryString = (
|
||||||
`size=${options.size || DEFAULT_SEARCH_SIZE}`,
|
`size=${options.size || DEFAULT_SEARCH_SIZE}`,
|
||||||
`from=${options.from || DEFAULT_SEARCH_RESULT_FROM}`,
|
`from=${options.from || DEFAULT_SEARCH_RESULT_FROM}`,
|
||||||
];
|
];
|
||||||
|
const { isBackgroundSearch } = options;
|
||||||
|
const includeUserOptions = typeof isBackgroundSearch === 'undefined' ? false : !isBackgroundSearch;
|
||||||
|
|
||||||
if (includeUserOptions) {
|
if (includeUserOptions) {
|
||||||
const claimType = options[SEARCH_OPTIONS.CLAIM_TYPE];
|
const claimType = options[SEARCH_OPTIONS.CLAIM_TYPE];
|
||||||
|
@ -68,6 +68,12 @@ export const getSearchQueryString = (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const additionalOptions = {}
|
||||||
|
const { related_to } = options;
|
||||||
|
const { nsfw } = options;
|
||||||
|
if (related_to) additionalOptions['related_to'] = related_to;
|
||||||
|
if (typeof nsfw !== 'undefined') additionalOptions['nsfw'] = nsfw;
|
||||||
|
|
||||||
if (additionalOptions) {
|
if (additionalOptions) {
|
||||||
Object.keys(additionalOptions).forEach(key => {
|
Object.keys(additionalOptions).forEach(key => {
|
||||||
const option = additionalOptions[key];
|
const option = additionalOptions[key];
|
||||||
|
|
Loading…
Add table
Reference in a new issue