Rename pending to fetching in selectors to avoid confusion
This commit is contained in:
parent
6c6f1beb19
commit
f3fdf5e841
9 changed files with 34 additions and 56 deletions
|
@ -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());
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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 => ({
|
||||
|
|
|
@ -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 = <FileList fileInfos={fileInfos} fetching={isPending} />;
|
||||
content = <FileList fileInfos={fileInfos} fetching={isFetching} />;
|
||||
} else {
|
||||
if (isPending) {
|
||||
if (isFetching) {
|
||||
content = <BusyMessage message={__("Loading")} />;
|
||||
} else {
|
||||
content = (
|
||||
|
|
|
@ -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 => ({
|
||||
|
|
|
@ -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 = (
|
||||
<FileList
|
||||
fileInfos={fileInfos}
|
||||
fetching={isPending}
|
||||
fetching={isFetching}
|
||||
fileTileShowEmpty={FileTile.SHOW_EMPTY_PENDING}
|
||||
/>
|
||||
);
|
||||
} else {
|
||||
if (isPending) {
|
||||
if (isFetching) {
|
||||
content = <BusyMessage message={__("Loading")} />;
|
||||
} else {
|
||||
content = (
|
||||
|
|
|
@ -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,
|
||||
});
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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) => {
|
||||
|
|
Loading…
Reference in a new issue