Fix issues with viewing most recent and uninitiated latest videos
This commit is contained in:
parent
c3dd7f3449
commit
2c6f2d52bf
3 changed files with 24 additions and 5 deletions
|
@ -4,6 +4,7 @@ import { doFetchFileInfo } from 'redux/actions/file_info';
|
||||||
import { makeSelectFileInfoForUri } from 'redux/selectors/file_info';
|
import { makeSelectFileInfoForUri } from 'redux/selectors/file_info';
|
||||||
import { selectRewardContentClaimIds } from 'redux/selectors/content';
|
import { selectRewardContentClaimIds } from 'redux/selectors/content';
|
||||||
import { doFetchCostInfoForUri } from 'redux/actions/cost_info';
|
import { doFetchCostInfoForUri } from 'redux/actions/cost_info';
|
||||||
|
import { checkSubscriptionLatest } from 'redux/actions/subscriptions';
|
||||||
import {
|
import {
|
||||||
makeSelectClaimForUri,
|
makeSelectClaimForUri,
|
||||||
makeSelectContentTypeForUri,
|
makeSelectContentTypeForUri,
|
||||||
|
@ -29,6 +30,7 @@ const perform = dispatch => ({
|
||||||
navigate: (path, params) => dispatch(doNavigate(path, params)),
|
navigate: (path, params) => dispatch(doNavigate(path, params)),
|
||||||
fetchFileInfo: uri => dispatch(doFetchFileInfo(uri)),
|
fetchFileInfo: uri => dispatch(doFetchFileInfo(uri)),
|
||||||
fetchCostInfo: uri => dispatch(doFetchCostInfoForUri(uri)),
|
fetchCostInfo: uri => dispatch(doFetchCostInfoForUri(uri)),
|
||||||
|
checkSubscriptionLatest: (subscription, uri) => dispatch(checkSubscriptionLatest(subscription, uri)),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(select, perform)(FilePage);
|
export default connect(select, perform)(FilePage);
|
||||||
|
|
|
@ -17,6 +17,7 @@ class FilePage extends React.PureComponent {
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.fetchFileInfo(this.props);
|
this.fetchFileInfo(this.props);
|
||||||
this.fetchCostInfo(this.props);
|
this.fetchCostInfo(this.props);
|
||||||
|
this.checkSubscriptionLatest(this.props);
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillReceiveProps(nextProps) {
|
componentWillReceiveProps(nextProps) {
|
||||||
|
@ -35,6 +36,13 @@ class FilePage extends React.PureComponent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkSubscriptionLatest(props) {
|
||||||
|
props.checkSubscriptionLatest({
|
||||||
|
channelName: props.claim.channel_name,
|
||||||
|
uri: `${props.claim.channel_name}#${props.claim.value.publisherSignature.certificateId}`,
|
||||||
|
}, `${props.claim.name}#${props.claim.claim_id}`);
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
claim,
|
claim,
|
||||||
|
|
|
@ -41,7 +41,7 @@ export const doCheckSubscription = (subscription: Subscription) => (dispatch: Di
|
||||||
const claimResult = result[subscription.uri] || {};
|
const claimResult = result[subscription.uri] || {};
|
||||||
const { claims_in_channel: claimsInChannel } = claimResult;
|
const { claims_in_channel: claimsInChannel } = claimResult;
|
||||||
|
|
||||||
let count = claimsInChannel.reduce((prev, cur, index) => `${cur.name}#${cur.claim_id}` === subscription.latest ? index : prev, -1)
|
let count = subscription.latest ? claimsInChannel.reduce((prev, cur, index) => `${cur.name}#${cur.claim_id}` === subscription.latest ? index : prev, -1) : 1;
|
||||||
|
|
||||||
if(count !== 0) {
|
if(count !== 0) {
|
||||||
if(!claimsInChannel[0].value.stream.metadata.fee) {
|
if(!claimsInChannel[0].value.stream.metadata.fee) {
|
||||||
|
@ -64,16 +64,25 @@ export const doCheckSubscription = (subscription: Subscription) => (dispatch: Di
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const checkSubscriptionLatest = (channel: Subscription, uri: string) => (dispatch: Dispatch) => {
|
||||||
|
Lbry.claim_list_by_channel({ uri: channel.uri, page: 1 }).then(result => {
|
||||||
|
const claimResult = result[channel.uri] || {};
|
||||||
|
const { claims_in_channel: claimsInChannel } = claimResult;
|
||||||
|
|
||||||
|
if(claimsInChannel && claimsInChannel.length && `${claimsInChannel[0].name}#${claimsInChannel[0].claim_id}` === uri) {
|
||||||
|
dispatch(setSubscriptionLatest(channel, uri));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export const setSubscriptionLatest = (subscription: Subscription, uri: string) => (dispatch: Dispatch) =>
|
export const setSubscriptionLatest = (subscription: Subscription, uri: string) => (dispatch: Dispatch) =>
|
||||||
{
|
dispatch({
|
||||||
return dispatch({
|
|
||||||
type: ACTIONS.SET_SUBSCRIPTION_LATEST,
|
type: ACTIONS.SET_SUBSCRIPTION_LATEST,
|
||||||
data: {
|
data: {
|
||||||
subscription,
|
subscription,
|
||||||
uri
|
uri
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
};
|
|
||||||
|
|
||||||
export const setHasFetchedSubscriptions = () => (dispatch: Dispatch) =>
|
export const setHasFetchedSubscriptions = () => (dispatch: Dispatch) =>
|
||||||
dispatch({ type: ACTIONS.HAS_FETCHED_SUBSCRIPTIONS });
|
dispatch({ type: ACTIONS.HAS_FETCHED_SUBSCRIPTIONS });
|
||||||
|
|
Loading…
Reference in a new issue