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