Fix recurring download problem, notification error and consolidate actions
This commit is contained in:
parent
2e91cd69b6
commit
7828753d49
4 changed files with 22 additions and 34 deletions
|
@ -4,7 +4,7 @@ import { doFetchFileInfo } from 'redux/actions/file_info';
|
|||
import { makeSelectFileInfoForUri } from 'redux/selectors/file_info';
|
||||
import { selectRewardContentClaimIds } from 'redux/selectors/content';
|
||||
import { doFetchCostInfoForUri } from 'redux/actions/cost_info';
|
||||
import { checkSubscriptionLatest } from 'redux/actions/subscriptions';
|
||||
import { doCheckSubscription } from 'redux/actions/subscriptions';
|
||||
import {
|
||||
makeSelectClaimForUri,
|
||||
makeSelectContentTypeForUri,
|
||||
|
@ -32,8 +32,8 @@ const perform = dispatch => ({
|
|||
navigate: (path, params) => dispatch(doNavigate(path, params)),
|
||||
fetchFileInfo: uri => dispatch(doFetchFileInfo(uri)),
|
||||
fetchCostInfo: uri => dispatch(doFetchCostInfoForUri(uri)),
|
||||
checkSubscriptionLatest: (subscription, uri) =>
|
||||
dispatch(checkSubscriptionLatest(subscription, uri)),
|
||||
checkSubscription: (subscription) =>
|
||||
dispatch(doCheckSubscription(subscription)),
|
||||
});
|
||||
|
||||
export default connect(select, perform)(FilePage);
|
||||
|
|
|
@ -17,7 +17,7 @@ class FilePage extends React.PureComponent {
|
|||
componentDidMount() {
|
||||
this.fetchFileInfo(this.props);
|
||||
this.fetchCostInfo(this.props);
|
||||
this.checkSubscriptionLatest(this.props);
|
||||
this.checkSubscription(this.props);
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
|
@ -36,13 +36,13 @@ class FilePage extends React.PureComponent {
|
|||
}
|
||||
}
|
||||
|
||||
checkSubscriptionLatest(props) {
|
||||
checkSubscription(props) {
|
||||
if (
|
||||
props.subscriptions
|
||||
.map(subscription => subscription.channelName)
|
||||
.indexOf(props.claim.channel_name) !== -1
|
||||
) {
|
||||
props.checkSubscriptionLatest(
|
||||
props.checkSubscription(
|
||||
{
|
||||
channelName: props.claim.channel_name,
|
||||
uri: buildURI(
|
||||
|
@ -52,9 +52,7 @@ class FilePage extends React.PureComponent {
|
|||
},
|
||||
false
|
||||
),
|
||||
},
|
||||
buildURI({ contentName: props.claim.name, claimId: props.claim.claim_id }, false)
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -165,7 +165,7 @@ export function doUpdateLoadStatus(uri, outpoint) {
|
|||
setProgressBar(totalProgress);
|
||||
|
||||
const notif = new window.Notification('LBRY Download Complete', {
|
||||
body: fileInfo.metadata.stream.metadata.title,
|
||||
body: fileInfo.metadata.title,
|
||||
silent: false,
|
||||
});
|
||||
notif.onclick = () => {
|
||||
|
|
|
@ -28,7 +28,7 @@ export const doCheckSubscriptions = () => (
|
|||
const checkSubscriptionsTimer = setInterval(
|
||||
() =>
|
||||
selectSubscriptions(getState()).map((subscription: Subscription) =>
|
||||
dispatch(doCheckSubscription(subscription))
|
||||
dispatch(doCheckSubscription(subscription, true))
|
||||
),
|
||||
CHECK_SUBSCRIPTIONS_INTERVAL
|
||||
);
|
||||
|
@ -38,7 +38,7 @@ export const doCheckSubscriptions = () => (
|
|||
});
|
||||
};
|
||||
|
||||
export const doCheckSubscription = (subscription: Subscription) => (dispatch: Dispatch) => {
|
||||
export const doCheckSubscription = (subscription: Subscription, notify?: boolean) => (dispatch: Dispatch) => {
|
||||
dispatch({
|
||||
type: ACTIONS.CHECK_SUBSCRIPTION_STARTED,
|
||||
data: subscription,
|
||||
|
@ -59,7 +59,7 @@ export const doCheckSubscription = (subscription: Subscription) => (dispatch: Di
|
|||
)
|
||||
: 1;
|
||||
|
||||
if (count !== 0) {
|
||||
if (count !== 0 && notify) {
|
||||
if (!claimsInChannel[0].value.stream.metadata.fee) {
|
||||
dispatch(
|
||||
doPurchaseUri(
|
||||
|
@ -90,7 +90,17 @@ export const doCheckSubscription = (subscription: Subscription) => (dispatch: Di
|
|||
};
|
||||
}
|
||||
|
||||
//$FlowIssue
|
||||
dispatch(setSubscriptionLatest({
|
||||
channelName: claimsInChannel[0].channel_name,
|
||||
uri: buildURI(
|
||||
{ channelName: claimsInChannel[0].channel_name, claimId: claimsInChannel[0].claim_id },
|
||||
false
|
||||
)
|
||||
}, buildURI(
|
||||
{ contentName: claimsInChannel[0].name, claimId: claimsInChannel[0].claim_id },
|
||||
false
|
||||
)));
|
||||
|
||||
dispatch({
|
||||
type: ACTIONS.CHECK_SUBSCRIPTION_COMPLETED,
|
||||
data: subscription,
|
||||
|
@ -98,26 +108,6 @@ 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 &&
|
||||
buildURI(
|
||||
{ contentName: claimsInChannel[0].name, claimId: claimsInChannel[0].claim_id },
|
||||
false
|
||||
) === uri
|
||||
) {
|
||||
dispatch(setSubscriptionLatest(channel, uri));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const setSubscriptionLatest = (subscription: Subscription, uri: string) => (
|
||||
dispatch: Dispatch
|
||||
) =>
|
||||
|
|
Loading…
Reference in a new issue