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 { 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 { doCheckSubscription } from 'redux/actions/subscriptions';
|
||||||
import {
|
import {
|
||||||
makeSelectClaimForUri,
|
makeSelectClaimForUri,
|
||||||
makeSelectContentTypeForUri,
|
makeSelectContentTypeForUri,
|
||||||
|
@ -32,8 +32,8 @@ 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) =>
|
checkSubscription: (subscription) =>
|
||||||
dispatch(checkSubscriptionLatest(subscription, uri)),
|
dispatch(doCheckSubscription(subscription)),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(select, perform)(FilePage);
|
export default connect(select, perform)(FilePage);
|
||||||
|
|
|
@ -17,7 +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);
|
this.checkSubscription(this.props);
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillReceiveProps(nextProps) {
|
componentWillReceiveProps(nextProps) {
|
||||||
|
@ -36,13 +36,13 @@ class FilePage extends React.PureComponent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
checkSubscriptionLatest(props) {
|
checkSubscription(props) {
|
||||||
if (
|
if (
|
||||||
props.subscriptions
|
props.subscriptions
|
||||||
.map(subscription => subscription.channelName)
|
.map(subscription => subscription.channelName)
|
||||||
.indexOf(props.claim.channel_name) !== -1
|
.indexOf(props.claim.channel_name) !== -1
|
||||||
) {
|
) {
|
||||||
props.checkSubscriptionLatest(
|
props.checkSubscription(
|
||||||
{
|
{
|
||||||
channelName: props.claim.channel_name,
|
channelName: props.claim.channel_name,
|
||||||
uri: buildURI(
|
uri: buildURI(
|
||||||
|
@ -52,9 +52,7 @@ class FilePage extends React.PureComponent {
|
||||||
},
|
},
|
||||||
false
|
false
|
||||||
),
|
),
|
||||||
},
|
});
|
||||||
buildURI({ contentName: props.claim.name, claimId: props.claim.claim_id }, false)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -165,7 +165,7 @@ export function doUpdateLoadStatus(uri, outpoint) {
|
||||||
setProgressBar(totalProgress);
|
setProgressBar(totalProgress);
|
||||||
|
|
||||||
const notif = new window.Notification('LBRY Download Complete', {
|
const notif = new window.Notification('LBRY Download Complete', {
|
||||||
body: fileInfo.metadata.stream.metadata.title,
|
body: fileInfo.metadata.title,
|
||||||
silent: false,
|
silent: false,
|
||||||
});
|
});
|
||||||
notif.onclick = () => {
|
notif.onclick = () => {
|
||||||
|
|
|
@ -28,7 +28,7 @@ export const doCheckSubscriptions = () => (
|
||||||
const checkSubscriptionsTimer = setInterval(
|
const checkSubscriptionsTimer = setInterval(
|
||||||
() =>
|
() =>
|
||||||
selectSubscriptions(getState()).map((subscription: Subscription) =>
|
selectSubscriptions(getState()).map((subscription: Subscription) =>
|
||||||
dispatch(doCheckSubscription(subscription))
|
dispatch(doCheckSubscription(subscription, true))
|
||||||
),
|
),
|
||||||
CHECK_SUBSCRIPTIONS_INTERVAL
|
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({
|
dispatch({
|
||||||
type: ACTIONS.CHECK_SUBSCRIPTION_STARTED,
|
type: ACTIONS.CHECK_SUBSCRIPTION_STARTED,
|
||||||
data: subscription,
|
data: subscription,
|
||||||
|
@ -59,7 +59,7 @@ export const doCheckSubscription = (subscription: Subscription) => (dispatch: Di
|
||||||
)
|
)
|
||||||
: 1;
|
: 1;
|
||||||
|
|
||||||
if (count !== 0) {
|
if (count !== 0 && notify) {
|
||||||
if (!claimsInChannel[0].value.stream.metadata.fee) {
|
if (!claimsInChannel[0].value.stream.metadata.fee) {
|
||||||
dispatch(
|
dispatch(
|
||||||
doPurchaseUri(
|
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({
|
dispatch({
|
||||||
type: ACTIONS.CHECK_SUBSCRIPTION_COMPLETED,
|
type: ACTIONS.CHECK_SUBSCRIPTION_COMPLETED,
|
||||||
data: subscription,
|
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) => (
|
export const setSubscriptionLatest = (subscription: Subscription, uri: string) => (
|
||||||
dispatch: Dispatch
|
dispatch: Dispatch
|
||||||
) =>
|
) =>
|
||||||
|
|
Loading…
Reference in a new issue