Wild West is now a real category, so can't use dynamicRouteProps === null to identify it.

A bit troublesome to handle, but at least the code is clearer now.
This commit is contained in:
infinite-persistence 2022-04-19 19:29:39 +08:00
parent d52593f3b2
commit 778ef649e8
No known key found for this signature in database
GPG key ID: B9C3252EDC3D0AA0
2 changed files with 9 additions and 14 deletions

View file

@ -199,9 +199,7 @@ function AppRouter(props: Props) {
<Route <Route
key={dynamicRouteProps.route} key={dynamicRouteProps.route}
path={dynamicRouteProps.route} path={dynamicRouteProps.route}
component={(routerProps) => ( component={(routerProps) => <DiscoverPage {...routerProps} dynamicRouteProps={dynamicRouteProps} />}
<DiscoverPage {...routerProps} dynamicRouteProps={dynamicRouteProps} hideRepostRibbon />
)}
/> />
)); ));
}, [homepageData, isLargeScreen, wildWestDisabled]); }, [homepageData, isLargeScreen, wildWestDisabled]);

View file

@ -25,7 +25,6 @@ type Props = {
followedTags: Array<Tag>, followedTags: Array<Tag>,
repostedUri: string, repostedUri: string,
repostedClaim: ?GenericClaim, repostedClaim: ?GenericClaim,
hideRepostRibbon?: boolean,
languageSetting: string, languageSetting: string,
searchInLanguage: boolean, searchInLanguage: boolean,
doToggleTagFollowDesktop: (string) => void, doToggleTagFollowDesktop: (string) => void,
@ -41,7 +40,6 @@ function DiscoverPage(props: Props) {
followedTags, followedTags,
repostedClaim, repostedClaim,
repostedUri, repostedUri,
hideRepostRibbon,
languageSetting, languageSetting,
searchInLanguage, searchInLanguage,
doToggleTagFollowDesktop, doToggleTagFollowDesktop,
@ -55,7 +53,7 @@ function DiscoverPage(props: Props) {
const buttonRef = useRef(); const buttonRef = useRef();
const isHovering = useHover(buttonRef); const isHovering = useHover(buttonRef);
const isMobile = useIsMobile(); const isMobile = useIsMobile();
const isWildWest = window.location.pathname === `/$/${PAGES.WILD_WEST}`; const isWildWest = dynamicRouteProps && dynamicRouteProps.id === 'WILD_WEST';
const urlParams = new URLSearchParams(search); const urlParams = new URLSearchParams(search);
const langParam = urlParams.get(CS.LANGUAGE_KEY) || null; const langParam = urlParams.get(CS.LANGUAGE_KEY) || null;
@ -63,9 +61,8 @@ function DiscoverPage(props: Props) {
const tagsQuery = urlParams.get('t') || null; const tagsQuery = urlParams.get('t') || null;
const tags = tagsQuery ? tagsQuery.split(',') : null; const tags = tagsQuery ? tagsQuery.split(',') : null;
const repostedClaimIsResolved = repostedUri && repostedClaim; const repostedClaimIsResolved = repostedUri && repostedClaim;
const hideRepostRibbon = !isWildWest;
const discoverIcon = SIMPLE_SITE ? ICONS.WILD_WEST : ICONS.DISCOVER;
const discoverLabel = SIMPLE_SITE ? __('Wild West') : __('All Content');
// Eventually allow more than one tag on this page // Eventually allow more than one tag on this page
// Restricting to one to make follow/unfollow simpler // Restricting to one to make follow/unfollow simpler
const tag = (tags && tags[0]) || null; const tag = (tags && tags[0]) || null;
@ -172,15 +169,15 @@ function DiscoverPage(props: Props) {
} else { } else {
headerLabel = ( headerLabel = (
<span> <span>
<Icon icon={(dynamicRouteProps && dynamicRouteProps.icon) || discoverIcon} size={10} /> <Icon icon={(dynamicRouteProps && dynamicRouteProps.icon) || ICONS.DISCOVER} size={10} />
{(dynamicRouteProps && __(`${dynamicRouteProps.title}`)) || discoverLabel} {(dynamicRouteProps && __(`${dynamicRouteProps.title}`)) || __('All Content')}
</span> </span>
); );
} }
let releaseTime = let releaseTime =
dynamicRouteProps && dynamicRouteProps.options && dynamicRouteProps.options.releaseTime dynamicRouteProps && dynamicRouteProps.options && dynamicRouteProps.options.releaseTime
? dynamicRouteProps.options.releaseTime ? dynamicRouteProps.options.releaseTime
: !dynamicRouteProps && !tags && `>${Math.floor(moment().subtract(0, 'hour').startOf('week').unix())}`; : !isWildWest && `>${Math.floor(moment().subtract(0, 'hour').startOf('week').unix())}`;
return ( return (
<Page <Page
@ -190,11 +187,11 @@ function DiscoverPage(props: Props) {
> >
<ClaimListDiscover <ClaimListDiscover
pins={getPins(dynamicRouteProps)} pins={getPins(dynamicRouteProps)}
hideFilters={SIMPLE_SITE ? !(dynamicRouteProps || tags) : undefined} hideFilters={isWildWest ? true : undefined}
header={repostedUri ? <span /> : undefined} header={repostedUri ? <span /> : undefined}
subSection={getSubSection()} subSection={getSubSection()}
tileLayout={repostedUri ? false : tileLayout} tileLayout={repostedUri ? false : tileLayout}
defaultOrderBy={SIMPLE_SITE ? (dynamicRouteProps ? undefined : CS.ORDER_BY_TRENDING) : undefined} defaultOrderBy={isWildWest || tags ? CS.ORDER_BY_TRENDING : undefined}
claimType={claimType ? [claimType] : undefined} claimType={claimType ? [claimType] : undefined}
headerLabel={headerLabel} headerLabel={headerLabel}
tags={tags} tags={tags}
@ -207,7 +204,7 @@ function DiscoverPage(props: Props) {
// TODO: find a better way to determine discover / wild west vs other modes release times // TODO: find a better way to determine discover / wild west vs other modes release times
// for now including && !tags so that // for now including && !tags so that
releaseTime={releaseTime || undefined} releaseTime={releaseTime || undefined}
feeAmount={SIMPLE_SITE ? !dynamicRouteProps && CS.FEE_AMOUNT_ANY : undefined} feeAmount={isWildWest || tags ? CS.FEE_AMOUNT_ANY : undefined}
channelIds={channelIds} channelIds={channelIds}
limitClaimsPerChannel={ limitClaimsPerChannel={
SIMPLE_SITE SIMPLE_SITE