use claim_id for reposts page instead of uri so we don't have to resolve before
This commit is contained in:
parent
5b587646ae
commit
b494c061aa
4 changed files with 12 additions and 26 deletions
|
@ -52,7 +52,7 @@ function FileActions(props: Props) {
|
||||||
<Button
|
<Button
|
||||||
button="alt"
|
button="alt"
|
||||||
label={__('(%count%)', { count: claim.meta.reposted })}
|
label={__('(%count%)', { count: claim.meta.reposted })}
|
||||||
navigate={`/$/${PAGES.DISCOVER}?${CS.REPOSTED_URI_KEY}=${encodeURIComponent(uri)}`}
|
navigate={`/$/${PAGES.DISCOVER}?${CS.REPOSTED_CLAIM_ID_KEY}=${claim.claim_id}`}
|
||||||
/>
|
/>
|
||||||
</Fragment>
|
</Fragment>
|
||||||
);
|
);
|
||||||
|
|
|
@ -5,7 +5,7 @@ export const ORDER_BY_KEY = 'order';
|
||||||
export const DURATION_KEY = 'duration';
|
export const DURATION_KEY = 'duration';
|
||||||
export const TAGS_KEY = 't';
|
export const TAGS_KEY = 't';
|
||||||
export const CONTENT_KEY = 'content';
|
export const CONTENT_KEY = 'content';
|
||||||
export const REPOSTED_URI_KEY = 'reposted_uri';
|
export const REPOSTED_CLAIM_ID_KEY = 'reposted_claim_id';
|
||||||
|
|
||||||
export const TAGS_ALL = 'tags_any';
|
export const TAGS_ALL = 'tags_any';
|
||||||
export const TAGS_FOLLOWED = 'tags_followed';
|
export const TAGS_FOLLOWED = 'tags_followed';
|
||||||
|
|
|
@ -1,24 +1,21 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { makeSelectClaimForUri, selectFollowedTags, doResolveUri } from 'lbry-redux';
|
import { selectFollowedTags } from 'lbry-redux';
|
||||||
import { selectUserVerifiedEmail } from 'lbryinc';
|
import { selectUserVerifiedEmail } from 'lbryinc';
|
||||||
import { doToggleTagFollowDesktop } from 'redux/actions/tags';
|
import { doToggleTagFollowDesktop } from 'redux/actions/tags';
|
||||||
import * as CS from 'constants/claim_search';
|
import * as CS from 'constants/claim_search';
|
||||||
import Tags from './view';
|
import Discover from './view';
|
||||||
|
|
||||||
const select = (state, props) => {
|
const select = (state, props) => {
|
||||||
const urlParams = new URLSearchParams(props.location.search);
|
const urlParams = new URLSearchParams(props.location.search);
|
||||||
const repostedUriInUrl = urlParams.get(CS.REPOSTED_URI_KEY);
|
const repostedClaimId = urlParams.get(CS.REPOSTED_CLAIM_ID_KEY);
|
||||||
const repostedUri = repostedUriInUrl ? decodeURIComponent(repostedUriInUrl) : undefined;
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
followedTags: selectFollowedTags(state),
|
followedTags: selectFollowedTags(state),
|
||||||
repostedUri: repostedUri,
|
repostedClaimId: repostedClaimId,
|
||||||
repostedClaim: repostedUri ? makeSelectClaimForUri(repostedUri)(state) : null,
|
|
||||||
isAuthenticated: selectUserVerifiedEmail(state),
|
isAuthenticated: selectUserVerifiedEmail(state),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export default connect(select, {
|
export default connect(select, {
|
||||||
doToggleTagFollowDesktop,
|
doToggleTagFollowDesktop,
|
||||||
doResolveUri,
|
})(Discover);
|
||||||
})(Tags);
|
|
||||||
|
|
|
@ -14,10 +14,8 @@ import Ads from 'lbrytv/component/ads';
|
||||||
type Props = {
|
type Props = {
|
||||||
location: { search: string },
|
location: { search: string },
|
||||||
followedTags: Array<Tag>,
|
followedTags: Array<Tag>,
|
||||||
repostedUri: string,
|
repostedClaimId: string,
|
||||||
repostedClaim: ?GenericClaim,
|
|
||||||
doToggleTagFollowDesktop: string => void,
|
doToggleTagFollowDesktop: string => void,
|
||||||
doResolveUri: string => void,
|
|
||||||
isAuthenticated: boolean,
|
isAuthenticated: boolean,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -25,10 +23,8 @@ function DiscoverPage(props: Props) {
|
||||||
const {
|
const {
|
||||||
location: { search },
|
location: { search },
|
||||||
followedTags,
|
followedTags,
|
||||||
repostedClaim,
|
repostedClaimId,
|
||||||
repostedUri,
|
|
||||||
doToggleTagFollowDesktop,
|
doToggleTagFollowDesktop,
|
||||||
doResolveUri,
|
|
||||||
isAuthenticated,
|
isAuthenticated,
|
||||||
} = props;
|
} = props;
|
||||||
const buttonRef = useRef();
|
const buttonRef = useRef();
|
||||||
|
@ -38,7 +34,6 @@ function DiscoverPage(props: Props) {
|
||||||
const claimType = urlParams.get('claim_type');
|
const claimType = urlParams.get('claim_type');
|
||||||
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;
|
|
||||||
|
|
||||||
// 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
|
||||||
|
@ -50,12 +45,6 @@ function DiscoverPage(props: Props) {
|
||||||
label = __('Unfollow');
|
label = __('Unfollow');
|
||||||
}
|
}
|
||||||
|
|
||||||
React.useEffect(() => {
|
|
||||||
if (repostedUri && !repostedClaimIsResolved) {
|
|
||||||
doResolveUri(repostedUri);
|
|
||||||
}
|
|
||||||
}, [repostedUri, repostedClaimIsResolved, doResolveUri]);
|
|
||||||
|
|
||||||
function handleFollowClick() {
|
function handleFollowClick() {
|
||||||
if (tag) {
|
if (tag) {
|
||||||
doToggleTagFollowDesktop(tag);
|
doToggleTagFollowDesktop(tag);
|
||||||
|
@ -66,8 +55,8 @@ function DiscoverPage(props: Props) {
|
||||||
}
|
}
|
||||||
|
|
||||||
let headerLabel;
|
let headerLabel;
|
||||||
if (repostedClaim) {
|
if (repostedClaimId) {
|
||||||
headerLabel = __('Reposts of %uri%', { uri: repostedUri });
|
headerLabel = __('Reposts');
|
||||||
} else if (tag) {
|
} else if (tag) {
|
||||||
headerLabel = (
|
headerLabel = (
|
||||||
<span>
|
<span>
|
||||||
|
@ -91,7 +80,7 @@ function DiscoverPage(props: Props) {
|
||||||
headerLabel={headerLabel}
|
headerLabel={headerLabel}
|
||||||
tags={tags}
|
tags={tags}
|
||||||
hiddenNsfwMessage={<HiddenNsfw type="page" />}
|
hiddenNsfwMessage={<HiddenNsfw type="page" />}
|
||||||
repostedClaimId={repostedClaim ? repostedClaim.claim_id : null}
|
repostedClaimId={repostedClaimId}
|
||||||
injectedItem={!isAuthenticated && IS_WEB && <Ads type="video" />}
|
injectedItem={!isAuthenticated && IS_WEB && <Ads type="video" />}
|
||||||
meta={
|
meta={
|
||||||
tag && (
|
tag && (
|
||||||
|
|
Loading…
Add table
Reference in a new issue