diff --git a/ui/js/actions/file_info.js b/ui/js/actions/file_info.js index 9d3861fb7..70db7244d 100644 --- a/ui/js/actions/file_info.js +++ b/ui/js/actions/file_info.js @@ -3,11 +3,11 @@ import lbry from "lbry"; import { doFetchClaimListMine } from "actions/content"; import { selectClaimsByUri, - selectClaimListMineIsPending, + selectIsFetchingClaimListMine, selectMyClaimsOutpoints, } from "selectors/claims"; import { - selectFileListIsPending, + selectIsFetchingFileList, selectFileInfosByOutpoint, selectUrisLoading, } from "selectors/file_info"; @@ -48,9 +48,9 @@ export function doFetchFileInfo(uri) { export function doFileList() { return function(dispatch, getState) { const state = getState(); - const isPending = selectFileListIsPending(state); + const isFetching = selectIsFetchingFileList(state); - if (!isPending) { + if (!isFetching) { dispatch({ type: types.FILE_LIST_STARTED, }); @@ -128,10 +128,10 @@ export function doDeleteFile(outpoint, deleteFromComputer, abandonClaim) { export function doFetchFileInfosAndPublishedClaims() { return function(dispatch, getState) { const state = getState(), - isClaimListMinePending = selectClaimListMineIsPending(state), - isFileInfoListPending = selectFileListIsPending(state); + isFetchingClaimListMine = selectIsFetchingClaimListMine(state), + isFetchingFileInfo = selectIsFetchingFileList(state); - dispatch(doFetchClaimListMine()); - dispatch(doFileList()); + if (!isFetchingClaimListMine) dispatch(doFetchClaimListMine()); + if (!isFetchingFileInfo) dispatch(doFileList()); }; } diff --git a/ui/js/page/fileListDownloaded/index.js b/ui/js/page/fileListDownloaded/index.js index 86d26d851..e51d5389f 100644 --- a/ui/js/page/fileListDownloaded/index.js +++ b/ui/js/page/fileListDownloaded/index.js @@ -3,7 +3,7 @@ import { connect } from "react-redux"; import { doFetchFileInfosAndPublishedClaims } from "actions/file_info"; import { selectFileInfosDownloaded, - selectFileListDownloadedOrPublishedIsPending, + selectIsFetchingFileListDownloadedOrPublished, } from "selectors/file_info"; import { doNavigate } from "actions/app"; import { doCancelAllResolvingUris } from "actions/content"; @@ -11,7 +11,7 @@ import FileListDownloaded from "./view"; const select = state => ({ fileInfos: selectFileInfosDownloaded(state), - isPending: selectFileListDownloadedOrPublishedIsPending(state), + isFetching: selectIsFetchingFileListDownloadedOrPublished(state), }); const perform = dispatch => ({ diff --git a/ui/js/page/fileListDownloaded/view.jsx b/ui/js/page/fileListDownloaded/view.jsx index 03665847c..c1501ec78 100644 --- a/ui/js/page/fileListDownloaded/view.jsx +++ b/ui/js/page/fileListDownloaded/view.jsx @@ -12,7 +12,7 @@ import SubHeader from "component/subHeader"; class FileListDownloaded extends React.PureComponent { componentWillMount() { - if (!this.props.isPending) this.props.fetchFileInfosDownloaded(); + if (!this.props.isFetching) this.props.fetchFileInfosDownloaded(); } componentWillUnmount() { @@ -20,13 +20,13 @@ class FileListDownloaded extends React.PureComponent { } render() { - const { fileInfos, isPending, navigate } = this.props; + const { fileInfos, isFetching, navigate } = this.props; let content; if (fileInfos && fileInfos.length > 0) { - content = ; + content = ; } else { - if (isPending) { + if (isFetching) { content = ; } else { content = ( diff --git a/ui/js/page/fileListPublished/index.js b/ui/js/page/fileListPublished/index.js index 7e5e349c3..9b8b2b80b 100644 --- a/ui/js/page/fileListPublished/index.js +++ b/ui/js/page/fileListPublished/index.js @@ -4,7 +4,7 @@ import { connect } from "react-redux"; import { doFetchFileInfosAndPublishedClaims } from "actions/file_info"; import { selectFileInfosPublished, - selectFileListDownloadedOrPublishedIsPending, + selectIsFetchingFileListDownloadedOrPublished, } from "selectors/file_info"; import { doClaimRewardType } from "actions/rewards"; import { doNavigate } from "actions/app"; @@ -13,7 +13,7 @@ import FileListPublished from "./view"; const select = state => ({ fileInfos: selectFileInfosPublished(state), - isPending: selectFileListDownloadedOrPublishedIsPending(state), + isFetching: selectIsFetchingFileListDownloadedOrPublished(state), }); const perform = dispatch => ({ diff --git a/ui/js/page/fileListPublished/view.jsx b/ui/js/page/fileListPublished/view.jsx index 822cfeb7d..fdcbe97cd 100644 --- a/ui/js/page/fileListPublished/view.jsx +++ b/ui/js/page/fileListPublished/view.jsx @@ -12,7 +12,7 @@ import SubHeader from "component/subHeader"; class FileListPublished extends React.PureComponent { componentWillMount() { - if (!this.props.isPending) this.props.fetchFileListPublished(); + if (!this.props.isFetching) this.props.fetchFileListPublished(); } componentDidUpdate() { @@ -24,7 +24,7 @@ class FileListPublished extends React.PureComponent { } render() { - const { fileInfos, isPending, navigate } = this.props; + const { fileInfos, isFetching, navigate } = this.props; let content; @@ -32,12 +32,12 @@ class FileListPublished extends React.PureComponent { content = ( ); } else { - if (isPending) { + if (isFetching) { content = ; } else { content = ( diff --git a/ui/js/reducers/claims.js b/ui/js/reducers/claims.js index 75bfc4a52..3ee992f94 100644 --- a/ui/js/reducers/claims.js +++ b/ui/js/reducers/claims.js @@ -34,7 +34,7 @@ reducers[types.RESOLVE_URI_COMPLETED] = function(state, action) { reducers[types.FETCH_CLAIM_LIST_MINE_STARTED] = function(state, action) { return Object.assign({}, state, { - isClaimListMinePending: true, + isFetchingClaimListMine: true, }); }; @@ -50,7 +50,7 @@ reducers[types.FETCH_CLAIM_LIST_MINE_COMPLETED] = function(state, action) { }); return Object.assign({}, state, { - isClaimListMinePending: false, + isFetchingClaimListMine: false, myClaims: myClaims, byId, }); diff --git a/ui/js/reducers/file_info.js b/ui/js/reducers/file_info.js index fe6979045..e462f3cf6 100644 --- a/ui/js/reducers/file_info.js +++ b/ui/js/reducers/file_info.js @@ -6,7 +6,7 @@ const defaultState = {}; reducers[types.FILE_LIST_STARTED] = function(state, action) { return Object.assign({}, state, { - isFileListPending: true, + isFetchingFileList: true, }); }; @@ -22,7 +22,7 @@ reducers[types.FILE_LIST_COMPLETED] = function(state, action) { }); return Object.assign({}, state, { - isFileListPending: false, + isFetchingFileList: false, byOutpoint: newByOutpoint, pendingByOutpoint, }); @@ -171,28 +171,6 @@ reducers[types.PUBLISH_FAILED] = function(state, action) { }); }; -// reducers[types.PUBLISH_COMPLETED] = function(state, action) { -// const { claim } = action.data; -// const uri = lbryuri.build({ -// txid: claim.txId -// }) -// const newPendingPublish = { -// name, -// channel_name, -// claim_id: "pending_claim_" + uri, -// txid: "pending_" + uri, -// nout: 0, -// outpoint: "pending_" + uri + ":0", -// time: Date.now(), -// }; -// const fileInfos = Object.assign({}, state.fileInfos) -// fileInfos[newPendingPublish.outpoint] = newPendingPublish - -// return Object.assign({}, state, { -// fileInfos, -// }) -// } - export default function reducer(state = defaultState, action) { const handler = reducers[action.type]; if (handler) return handler(state, action); diff --git a/ui/js/selectors/claims.js b/ui/js/selectors/claims.js index aa19a6e80..f0708cf86 100644 --- a/ui/js/selectors/claims.js +++ b/ui/js/selectors/claims.js @@ -100,9 +100,9 @@ export const makeSelectContentTypeForUri = () => { ); }; -export const selectClaimListMineIsPending = createSelector( +export const selectIsFetchingClaimListMine = createSelector( _selectState, - state => state.isClaimListMinePending + state => !!state.isFetchingClaimListMine ); export const selectMyClaimsRaw = createSelector( diff --git a/ui/js/selectors/file_info.js b/ui/js/selectors/file_info.js index 4010b95c8..7b8a10769 100644 --- a/ui/js/selectors/file_info.js +++ b/ui/js/selectors/file_info.js @@ -2,7 +2,7 @@ import lbry from "lbry"; import { createSelector } from "reselect"; import { selectClaimsByUri, - selectClaimListMineIsPending, + selectIsFetchingClaimListMine, selectMyClaimsOutpoints, } from "selectors/claims"; @@ -13,16 +13,16 @@ export const selectFileInfosByOutpoint = createSelector( state => state.byOutpoint || {} ); -export const selectFileListIsPending = createSelector( +export const selectIsFetchingFileList = createSelector( _selectState, - state => state.isFileListPending + state => !!state.isFetchingFileList ); -export const selectFileListDownloadedOrPublishedIsPending = createSelector( - selectFileListIsPending, - selectClaimListMineIsPending, - (isFileListPending, isClaimListMinePending) => - isFileListPending || isClaimListMinePending +export const selectIsFetchingFileListDownloadedOrPublished = createSelector( + selectIsFetchingFileList, + selectIsFetchingClaimListMine, + (isFetchingFileList, isFetchingClaimListMine) => + isFetchingFileList || isFetchingClaimListMine ); export const selectFileInfoForUri = (state, props) => {