fix reposts page when navigating directly by url

This commit is contained in:
Sean Yesmunt 2020-03-24 12:31:23 -04:00
parent 1875c37ed3
commit 6e953c098c
3 changed files with 21 additions and 7 deletions

View file

@ -136,7 +136,7 @@ function ClaimListDiscover(props: Props) {
claim_type?: Array<string>,
name?: string,
duration?: string,
reposted_claim_id: string,
reposted_claim_id?: string,
stream_types?: any,
} = {
page_size: pageSize || CS.PAGE_SIZE,
@ -598,9 +598,13 @@ function ClaimListDiscover(props: Props) {
hideBlock={hideBlock}
/>
<div className="card">
{loading && new Array(CS.PAGE_SIZE).fill(1).map((x, i) => <ClaimPreview key={i} placeholder="loading" />)}
</div>
{loading && (
<div className="card">
{new Array(CS.PAGE_SIZE).fill(1).map((x, i) => (
<ClaimPreview key={i} placeholder="loading" />
))}
</div>
)}
</React.Fragment>
);
}

View file

@ -1,5 +1,5 @@
import { connect } from 'react-redux';
import { makeSelectClaimForUri, selectFollowedTags } from 'lbry-redux';
import { makeSelectClaimForUri, selectFollowedTags, doResolveUri } from 'lbry-redux';
import { doToggleTagFollowDesktop } from 'redux/actions/tags';
import * as CS from 'constants/claim_search';
import Tags from './view';
@ -17,4 +17,5 @@ const select = (state, props) => {
export default connect(select, {
doToggleTagFollowDesktop,
doResolveUri,
})(Tags);

View file

@ -16,15 +16,17 @@ type Props = {
repostedUri: string,
repostedClaim: ?GenericClaim,
doToggleTagFollowDesktop: string => void,
doResolveUri: string => void,
};
function TagsPage(props: Props) {
function DiscoverPage(props: Props) {
const {
location: { search },
followedTags,
repostedClaim,
repostedUri,
doToggleTagFollowDesktop,
doResolveUri,
} = props;
const buttonRef = useRef();
const isHovering = useHover(buttonRef);
@ -33,6 +35,7 @@ function TagsPage(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
@ -44,6 +47,12 @@ function TagsPage(props: Props) {
label = __('Unfollow');
}
React.useEffect(() => {
if (repostedUri && !repostedClaimIsResolved) {
doResolveUri(repostedUri);
}
}, [repostedUri, repostedClaimIsResolved, doResolveUri]);
function handleFollowClick() {
if (tag) {
doToggleTagFollowDesktop(tag);
@ -98,4 +107,4 @@ function TagsPage(props: Props) {
);
}
export default TagsPage;
export default DiscoverPage;