~Final~ Discovery fixes/cleanup #2599

Merged
neb-b merged 16 commits from discovery-fixes into master 2019-07-05 20:03:12 +02:00
2 changed files with 12 additions and 2 deletions
Showing only changes of commit 101f511e85 - Show all commits

View file

@ -1,12 +1,15 @@
import * as SETTINGS from 'constants/settings';
import { connect } from 'react-redux';
import { doClaimSearch, selectLastClaimSearchUris, selectFetchingClaimSearch, doToggleTagFollow } from 'lbry-redux';
import { selectSubscriptions } from 'redux/selectors/subscriptions';
import { makeSelectClientSetting } from 'redux/selectors/settings';
import ClaimListDiscover from './view';
const select = state => ({
uris: selectLastClaimSearchUris(state),
loading: selectFetchingClaimSearch(state),
subscribedChannels: selectSubscriptions(state),
showNsfw: makeSelectClientSetting(SETTINGS.SHOW_NSFW)(state),
});
const perform = {

View file

@ -3,6 +3,7 @@ import type { Node } from 'react';
import React, { useEffect, useState } from 'react';
import moment from 'moment';
import usePersistedState from 'util/use-persisted-state';
import { MATURE_TAGS } from 'lbry-redux';
import { FormField } from 'component/common/form';
import ClaimList from 'component/claimList';
import Tag from 'component/tag';
@ -35,10 +36,11 @@ type Props = {
personal: boolean,
doToggleTagFollow: string => void,
meta?: Node,
showNsfw: boolean,
};
function ClaimListDiscover(props: Props) {
const { doClaimSearch, uris, tags, loading, personal, injectedItem, meta, subscribedChannels } = props;
const { doClaimSearch, uris, tags, loading, personal, injectedItem, meta, subscribedChannels, showNsfw } = props;
const [personalSort, setPersonalSort] = usePersistedState('claim-list-discover:personalSort', SEARCH_SORT_YOU);
const [typeSort, setTypeSort] = usePersistedState('claim-list-discover:typeSort', TYPE_TRENDING);
const [timeSort, setTimeSort] = usePersistedState('claim-list-discover:timeSort', TIME_WEEK);
@ -54,6 +56,7 @@ function ClaimListDiscover(props: Props) {
order_by?: Array<string>,
channel_ids?: Array<string>,
release_time?: string,
not_tags?: Array<string>,
} = { page_size: PAGE_SIZE, page };
const newTags = tagsString.split(',');
const newChannelIds = channelsIdString.split(',');
@ -64,6 +67,10 @@ function ClaimListDiscover(props: Props) {
options.channel_ids = newChannelIds;
}
if (!showNsfw) {
options.not_tags = MATURE_TAGS;
}
if (typeSort === TYPE_TRENDING) {
options.order_by = ['trending_global', 'trending_mixed'];
} else if (typeSort === TYPE_NEW) {
@ -81,7 +88,7 @@ function ClaimListDiscover(props: Props) {
}
doClaimSearch(20, options);
}, [personal, personalSort, typeSort, timeSort, doClaimSearch, page, tagsString, channelsIdString]);
}, [personal, personalSort, typeSort, timeSort, doClaimSearch, page, tagsString, channelsIdString, showNsfw]);
function getLabel(type) {
if (type === SEARCH_SORT_ALL) {