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
|
||||||
button="alt"
|
button="alt"
|
||||||
label={__('(%count%)', { count: claim.meta.reposted })}
|
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>
|
</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_CLAIM_ID_KEY = 'reposted_claim_id';
|
export const REPOSTED_URI_KEY = 'reposted_uri';
|
||||||
|
|
||||||
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,21 +1,24 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { selectFollowedTags } from 'lbry-redux';
|
import { makeSelectClaimForUri, selectFollowedTags, doResolveUri } 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 Discover from './view';
|
import Tags 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 repostedClaimId = urlParams.get(CS.REPOSTED_CLAIM_ID_KEY);
|
const repostedUriInUrl = urlParams.get(CS.REPOSTED_URI_KEY);
|
||||||
|
const repostedUri = repostedUriInUrl ? decodeURIComponent(repostedUriInUrl) : undefined;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
followedTags: selectFollowedTags(state),
|
followedTags: selectFollowedTags(state),
|
||||||
repostedClaimId: repostedClaimId,
|
repostedUri: repostedUri,
|
||||||
|
repostedClaim: repostedUri ? makeSelectClaimForUri(repostedUri)(state) : null,
|
||||||
isAuthenticated: selectUserVerifiedEmail(state),
|
isAuthenticated: selectUserVerifiedEmail(state),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export default connect(select, {
|
export default connect(select, {
|
||||||
doToggleTagFollowDesktop,
|
doToggleTagFollowDesktop,
|
||||||
})(Discover);
|
doResolveUri,
|
||||||
|
})(Tags);
|
||||||
|
|
|
@ -14,8 +14,10 @@ import Ads from 'lbrytv/component/ads';
|
||||||
type Props = {
|
type Props = {
|
||||||
location: { search: string },
|
location: { search: string },
|
||||||
followedTags: Array<Tag>,
|
followedTags: Array<Tag>,
|
||||||
repostedClaimId: string,
|
repostedUri: string,
|
||||||
|
repostedClaim: ?GenericClaim,
|
||||||
doToggleTagFollowDesktop: string => void,
|
doToggleTagFollowDesktop: string => void,
|
||||||
|
doResolveUri: string => void,
|
||||||
isAuthenticated: boolean,
|
isAuthenticated: boolean,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -23,8 +25,10 @@ function DiscoverPage(props: Props) {
|
||||||
const {
|
const {
|
||||||
location: { search },
|
location: { search },
|
||||||
followedTags,
|
followedTags,
|
||||||
repostedClaimId,
|
repostedClaim,
|
||||||
|
repostedUri,
|
||||||
doToggleTagFollowDesktop,
|
doToggleTagFollowDesktop,
|
||||||
|
doResolveUri,
|
||||||
isAuthenticated,
|
isAuthenticated,
|
||||||
} = props;
|
} = props;
|
||||||
const buttonRef = useRef();
|
const buttonRef = useRef();
|
||||||
|
@ -34,6 +38,7 @@ 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
|
||||||
|
@ -45,6 +50,12 @@ 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);
|
||||||
|
@ -55,8 +66,8 @@ function DiscoverPage(props: Props) {
|
||||||
}
|
}
|
||||||
|
|
||||||
let headerLabel;
|
let headerLabel;
|
||||||
if (repostedClaimId) {
|
if (repostedClaim) {
|
||||||
headerLabel = __('Reposts');
|
headerLabel = __('Reposts of %uri%', { uri: repostedUri });
|
||||||
} else if (tag) {
|
} else if (tag) {
|
||||||
headerLabel = (
|
headerLabel = (
|
||||||
<span>
|
<span>
|
||||||
|
@ -80,7 +91,7 @@ function DiscoverPage(props: Props) {
|
||||||
headerLabel={headerLabel}
|
headerLabel={headerLabel}
|
||||||
tags={tags}
|
tags={tags}
|
||||||
hiddenNsfwMessage={<HiddenNsfw type="page" />}
|
hiddenNsfwMessage={<HiddenNsfw type="page" />}
|
||||||
repostedClaimId={repostedClaimId}
|
repostedClaimId={repostedClaim ? repostedClaim.claim_id : null}
|
||||||
injectedItem={!isAuthenticated && IS_WEB && <Ads type="video" />}
|
injectedItem={!isAuthenticated && IS_WEB && <Ads type="video" />}
|
||||||
meta={
|
meta={
|
||||||
tag && (
|
tag && (
|
||||||
|
|
Loading…
Reference in a new issue