diff --git a/src/renderer/page/file/index.js b/src/renderer/page/file/index.js index 37fb13c7f..5116ebd5b 100644 --- a/src/renderer/page/file/index.js +++ b/src/renderer/page/file/index.js @@ -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); diff --git a/src/renderer/page/file/view.jsx b/src/renderer/page/file/view.jsx index 069a0dfdc..5ca16b600 100644 --- a/src/renderer/page/file/view.jsx +++ b/src/renderer/page/file/view.jsx @@ -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) - ); + }); } } diff --git a/src/renderer/redux/actions/content.js b/src/renderer/redux/actions/content.js index d5671bba4..5fd99c23e 100644 --- a/src/renderer/redux/actions/content.js +++ b/src/renderer/redux/actions/content.js @@ -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 = () => { diff --git a/src/renderer/redux/actions/subscriptions.js b/src/renderer/redux/actions/subscriptions.js index 7d2e40e5d..2233363a1 100644 --- a/src/renderer/redux/actions/subscriptions.js +++ b/src/renderer/redux/actions/subscriptions.js @@ -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 ) =>