Discover: fetch livestreams "per-language", if enabled.

Fetch it using the same language parameters for claim_search that is used in the embedded ClaimListDiscover.
This commit is contained in:
infinite-persistence 2022-02-24 19:56:36 +08:00 committed by Thomas Zarebczan
parent a14239a9dc
commit 99d8d0dbee
2 changed files with 13 additions and 7 deletions

View file

@ -8,7 +8,7 @@ import { selectActiveLivestreams } from 'redux/selectors/livestream';
import { selectUserVerifiedEmail } from 'redux/selectors/user';
import { selectFollowedTags } from 'redux/selectors/tags';
import { doToggleTagFollowDesktop } from 'redux/actions/tags';
import { selectClientSetting } from 'redux/selectors/settings';
import { selectClientSetting, selectLanguage } from 'redux/selectors/settings';
import Tags from './view';
const select = (state, props) => {
@ -23,6 +23,8 @@ const select = (state, props) => {
isAuthenticated: selectUserVerifiedEmail(state),
tileLayout: selectClientSetting(state, SETTINGS.TILE_LAYOUT),
activeLivestreams: selectActiveLivestreams(state),
languageSetting: selectLanguage(state),
searchInLanguage: selectClientSetting(state, SETTINGS.SEARCH_IN_LANGUAGE),
};
};

View file

@ -17,6 +17,7 @@ import Ads, { injectAd } from 'web/component/ads';
import LbcSymbol from 'component/common/lbc-symbol';
import I18nMessage from 'component/i18nMessage';
import moment from 'moment';
import { resolveLangForClaimSearch } from 'util/default-languages';
import { getLivestreamUris } from 'util/livestream';
const DEFAULT_LIVESTREAM_TILE_LIMIT = 8;
@ -29,12 +30,14 @@ type Props = {
followedTags: Array<Tag>,
repostedUri: string,
repostedClaim: ?GenericClaim,
languageSetting: string,
searchInLanguage: boolean,
doToggleTagFollowDesktop: (string) => void,
doResolveUri: (string) => void,
isAuthenticated: boolean,
tileLayout: boolean,
activeLivestreams: ?LivestreamInfo,
doFetchActiveLivestreams: (orderBy?: Array<string>) => void,
doFetchActiveLivestreams: (orderBy: ?Array<string>, lang: ?Array<string>) => void,
};
function DiscoverPage(props: Props) {
@ -43,6 +46,8 @@ function DiscoverPage(props: Props) {
followedTags,
repostedClaim,
repostedUri,
languageSetting,
searchInLanguage,
doToggleTagFollowDesktop,
doResolveUri,
isAuthenticated,
@ -61,6 +66,7 @@ function DiscoverPage(props: Props) {
const isLargeScreen = useIsLargeScreen();
const urlParams = new URLSearchParams(search);
const langParam = urlParams.get(CS.LANGUAGE_KEY) || null;
const claimType = urlParams.get('claim_type');
const tagsQuery = urlParams.get('t') || null;
const tags = tagsQuery ? tagsQuery.split(',') : null;
@ -202,11 +208,9 @@ function DiscoverPage(props: Props) {
// Fetch active livestreams on mount
React.useEffect(() => {
if (liveSection === SECTION.LESS) {
doFetchActiveLivestreams(CS.ORDER_BY_TRENDING_VALUE);
} else {
doFetchActiveLivestreams();
}
const langCsv = resolveLangForClaimSearch(languageSetting, searchInLanguage, langParam);
const lang = langCsv ? langCsv.split(',') : null;
doFetchActiveLivestreams(CS.ORDER_BY_NEW_VALUE, lang);
// eslint-disable-next-line react-hooks/exhaustive-deps, (on mount only)
}, []);