diff --git a/src/ui/page/fileListPublished/index.js b/src/ui/page/fileListPublished/index.js index 9a6c75c79..0be607a99 100644 --- a/src/ui/page/fileListPublished/index.js +++ b/src/ui/page/fileListPublished/index.js @@ -1,5 +1,6 @@ import { connect } from 'react-redux'; -import { selectIsFetchingClaimListMine, selectMyClaimUrisWithoutChannels, doCheckPendingPublishes } from 'lbry-redux'; +import { selectIsFetchingClaimListMine, selectMyClaimUrisWithoutChannels } from 'lbry-redux'; +import { doCheckPendingPublishesApp } from 'redux/actions/publish'; import FileListPublished from './view'; const select = state => ({ @@ -8,7 +9,7 @@ const select = state => ({ }); const perform = dispatch => ({ - checkPendingPublishes: () => dispatch(doCheckPendingPublishes()), + checkPendingPublishes: () => dispatch(doCheckPendingPublishesApp()), }); export default connect( diff --git a/src/ui/redux/actions/publish.js b/src/ui/redux/actions/publish.js index f68b2f052..9409d4774 100644 --- a/src/ui/redux/actions/publish.js +++ b/src/ui/redux/actions/publish.js @@ -4,23 +4,22 @@ import { batchActions, // selectPendingById, doError, - selectMyClaimsWithoutChannels, + selectMyClaims, doPublish, - // doCheckPendingPublishes, + doCheckPendingPublishes, } from 'lbry-redux'; import * as ACTIONS from 'constants/action_types'; -// import { selectosNotificationsEnabled } from 'redux/selectors/settings'; -// import { push } from 'connected-react-router'; -// import analytics from 'analytics'; -// import { formatLbryUriForWeb } from 'util/uri'; -import analytics from '../../analytics'; +import { selectosNotificationsEnabled } from 'redux/selectors/settings'; +import { push } from 'connected-react-router'; +import analytics from 'analytics'; +import { formatLbryUriForWeb } from 'util/uri'; import { doOpenModal } from './app'; export const doPublishDesktop = () => (dispatch: Dispatch, getState: () => {}) => { const publishSuccess = successResponse => { const state = getState(); analytics.apiLogPublish(); - const myClaims = selectMyClaimsWithoutChannels(state); + const myClaims = selectMyClaims(state); const pendingClaim = successResponse.outputs[0]; const uri = pendingClaim.permanent_url; const actions = []; @@ -58,54 +57,17 @@ export const doPublishDesktop = () => (dispatch: Dispatch, getState: () => {}) = }; // Calls claim_list_mine until any pending publishes are confirmed -export const doCheckPendingPublishesApp = () => (dispatch: Dispatch, getState: GetState) => {}; - -// export const doCheckPendingPublishes = () => (dispatch: Dispatch, getState: GetState) => { -// const state = getState(); -// const pendingById = selectPendingById(state); -// -// if (!Object.keys(pendingById).length) { -// return; -// } -// -// let publishCheckInterval; -// -// const checkFileList = () => { -// Lbry.claim_list().then(claims => { -// if (claims) { -// claims.forEach(claim => { -// // If it's confirmed, check if it was pending previously -// if (claim.confirmations > 0 && pendingById[claim.claim_id]) { -// delete pendingById[claim.claim_id]; -// -// // If it's confirmed, check if we should notify the user -// if (selectosNotificationsEnabled(getState())) { -// const notif = new window.Notification('LBRY Publish Complete', { -// body: `${claim.value.title} has been published to lbry://${claim.name}. Click here to view it`, -// silent: false, -// }); -// notif.onclick = () => { -// dispatch(push(formatLbryUriForWeb(claim.permanent_url))); -// }; -// } -// } -// }); -// } -// -// dispatch({ -// type: ACTIONS.FETCH_CLAIM_LIST_MINE_COMPLETED, -// data: { -// claims, -// }, -// }); -// -// if (!Object.keys(pendingById).length) { -// clearInterval(publishCheckInterval); -// } -// }); -// }; -// -// publishCheckInterval = setInterval(() => { -// checkFileList(); -// }, 30000); -// }; +export const doCheckPendingPublishesApp = () => (dispatch: Dispatch, getState: GetState) => { + const onConfirmed = claim => { + if (selectosNotificationsEnabled(getState())) { + const notif = new window.Notification('LBRY Publish Complete', { + body: `${claim.value.title} has been published to lbry://${claim.name}. Click here to view it`, + silent: false, + }); + notif.onclick = () => { + dispatch(push(formatLbryUriForWeb(claim.permanent_url))); + }; + } + }; + return dispatch(doCheckPendingPublishes(onConfirmed)); +};