Rename pending to fetching in selectors to avoid confusion

This commit is contained in:
6ea86b96 2017-07-04 18:05:35 +07:00
parent 6c6f1beb19
commit f3fdf5e841
9 changed files with 34 additions and 56 deletions

View file

@ -3,11 +3,11 @@ import lbry from "lbry";
import { doFetchClaimListMine } from "actions/content"; import { doFetchClaimListMine } from "actions/content";
import { import {
selectClaimsByUri, selectClaimsByUri,
selectClaimListMineIsPending, selectIsFetchingClaimListMine,
selectMyClaimsOutpoints, selectMyClaimsOutpoints,
} from "selectors/claims"; } from "selectors/claims";
import { import {
selectFileListIsPending, selectIsFetchingFileList,
selectFileInfosByOutpoint, selectFileInfosByOutpoint,
selectUrisLoading, selectUrisLoading,
} from "selectors/file_info"; } from "selectors/file_info";
@ -48,9 +48,9 @@ export function doFetchFileInfo(uri) {
export function doFileList() { export function doFileList() {
return function(dispatch, getState) { return function(dispatch, getState) {
const state = getState(); const state = getState();
const isPending = selectFileListIsPending(state); const isFetching = selectIsFetchingFileList(state);
if (!isPending) { if (!isFetching) {
dispatch({ dispatch({
type: types.FILE_LIST_STARTED, type: types.FILE_LIST_STARTED,
}); });
@ -128,10 +128,10 @@ export function doDeleteFile(outpoint, deleteFromComputer, abandonClaim) {
export function doFetchFileInfosAndPublishedClaims() { export function doFetchFileInfosAndPublishedClaims() {
return function(dispatch, getState) { return function(dispatch, getState) {
const state = getState(), const state = getState(),
isClaimListMinePending = selectClaimListMineIsPending(state), isFetchingClaimListMine = selectIsFetchingClaimListMine(state),
isFileInfoListPending = selectFileListIsPending(state); isFetchingFileInfo = selectIsFetchingFileList(state);
dispatch(doFetchClaimListMine()); if (!isFetchingClaimListMine) dispatch(doFetchClaimListMine());
dispatch(doFileList()); if (!isFetchingFileInfo) dispatch(doFileList());
}; };
} }

View file

@ -3,7 +3,7 @@ import { connect } from "react-redux";
import { doFetchFileInfosAndPublishedClaims } from "actions/file_info"; import { doFetchFileInfosAndPublishedClaims } from "actions/file_info";
import { import {
selectFileInfosDownloaded, selectFileInfosDownloaded,
selectFileListDownloadedOrPublishedIsPending, selectIsFetchingFileListDownloadedOrPublished,
} from "selectors/file_info"; } from "selectors/file_info";
import { doNavigate } from "actions/app"; import { doNavigate } from "actions/app";
import { doCancelAllResolvingUris } from "actions/content"; import { doCancelAllResolvingUris } from "actions/content";
@ -11,7 +11,7 @@ import FileListDownloaded from "./view";
const select = state => ({ const select = state => ({
fileInfos: selectFileInfosDownloaded(state), fileInfos: selectFileInfosDownloaded(state),
isPending: selectFileListDownloadedOrPublishedIsPending(state), isFetching: selectIsFetchingFileListDownloadedOrPublished(state),
}); });
const perform = dispatch => ({ const perform = dispatch => ({

View file

@ -12,7 +12,7 @@ import SubHeader from "component/subHeader";
class FileListDownloaded extends React.PureComponent { class FileListDownloaded extends React.PureComponent {
componentWillMount() { componentWillMount() {
if (!this.props.isPending) this.props.fetchFileInfosDownloaded(); if (!this.props.isFetching) this.props.fetchFileInfosDownloaded();
} }
componentWillUnmount() { componentWillUnmount() {
@ -20,13 +20,13 @@ class FileListDownloaded extends React.PureComponent {
} }
render() { render() {
const { fileInfos, isPending, navigate } = this.props; const { fileInfos, isFetching, navigate } = this.props;
let content; let content;
if (fileInfos && fileInfos.length > 0) { if (fileInfos && fileInfos.length > 0) {
content = <FileList fileInfos={fileInfos} fetching={isPending} />; content = <FileList fileInfos={fileInfos} fetching={isFetching} />;
} else { } else {
if (isPending) { if (isFetching) {
content = <BusyMessage message={__("Loading")} />; content = <BusyMessage message={__("Loading")} />;
} else { } else {
content = ( content = (

View file

@ -4,7 +4,7 @@ import { connect } from "react-redux";
import { doFetchFileInfosAndPublishedClaims } from "actions/file_info"; import { doFetchFileInfosAndPublishedClaims } from "actions/file_info";
import { import {
selectFileInfosPublished, selectFileInfosPublished,
selectFileListDownloadedOrPublishedIsPending, selectIsFetchingFileListDownloadedOrPublished,
} from "selectors/file_info"; } from "selectors/file_info";
import { doClaimRewardType } from "actions/rewards"; import { doClaimRewardType } from "actions/rewards";
import { doNavigate } from "actions/app"; import { doNavigate } from "actions/app";
@ -13,7 +13,7 @@ import FileListPublished from "./view";
const select = state => ({ const select = state => ({
fileInfos: selectFileInfosPublished(state), fileInfos: selectFileInfosPublished(state),
isPending: selectFileListDownloadedOrPublishedIsPending(state), isFetching: selectIsFetchingFileListDownloadedOrPublished(state),
}); });
const perform = dispatch => ({ const perform = dispatch => ({

View file

@ -12,7 +12,7 @@ import SubHeader from "component/subHeader";
class FileListPublished extends React.PureComponent { class FileListPublished extends React.PureComponent {
componentWillMount() { componentWillMount() {
if (!this.props.isPending) this.props.fetchFileListPublished(); if (!this.props.isFetching) this.props.fetchFileListPublished();
} }
componentDidUpdate() { componentDidUpdate() {
@ -24,7 +24,7 @@ class FileListPublished extends React.PureComponent {
} }
render() { render() {
const { fileInfos, isPending, navigate } = this.props; const { fileInfos, isFetching, navigate } = this.props;
let content; let content;
@ -32,12 +32,12 @@ class FileListPublished extends React.PureComponent {
content = ( content = (
<FileList <FileList
fileInfos={fileInfos} fileInfos={fileInfos}
fetching={isPending} fetching={isFetching}
fileTileShowEmpty={FileTile.SHOW_EMPTY_PENDING} fileTileShowEmpty={FileTile.SHOW_EMPTY_PENDING}
/> />
); );
} else { } else {
if (isPending) { if (isFetching) {
content = <BusyMessage message={__("Loading")} />; content = <BusyMessage message={__("Loading")} />;
} else { } else {
content = ( content = (

View file

@ -34,7 +34,7 @@ reducers[types.RESOLVE_URI_COMPLETED] = function(state, action) {
reducers[types.FETCH_CLAIM_LIST_MINE_STARTED] = function(state, action) { reducers[types.FETCH_CLAIM_LIST_MINE_STARTED] = function(state, action) {
return Object.assign({}, state, { 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, { return Object.assign({}, state, {
isClaimListMinePending: false, isFetchingClaimListMine: false,
myClaims: myClaims, myClaims: myClaims,
byId, byId,
}); });

View file

@ -6,7 +6,7 @@ const defaultState = {};
reducers[types.FILE_LIST_STARTED] = function(state, action) { reducers[types.FILE_LIST_STARTED] = function(state, action) {
return Object.assign({}, state, { return Object.assign({}, state, {
isFileListPending: true, isFetchingFileList: true,
}); });
}; };
@ -22,7 +22,7 @@ reducers[types.FILE_LIST_COMPLETED] = function(state, action) {
}); });
return Object.assign({}, state, { return Object.assign({}, state, {
isFileListPending: false, isFetchingFileList: false,
byOutpoint: newByOutpoint, byOutpoint: newByOutpoint,
pendingByOutpoint, 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) { export default function reducer(state = defaultState, action) {
const handler = reducers[action.type]; const handler = reducers[action.type];
if (handler) return handler(state, action); if (handler) return handler(state, action);

View file

@ -100,9 +100,9 @@ export const makeSelectContentTypeForUri = () => {
); );
}; };
export const selectClaimListMineIsPending = createSelector( export const selectIsFetchingClaimListMine = createSelector(
_selectState, _selectState,
state => state.isClaimListMinePending state => !!state.isFetchingClaimListMine
); );
export const selectMyClaimsRaw = createSelector( export const selectMyClaimsRaw = createSelector(

View file

@ -2,7 +2,7 @@ import lbry from "lbry";
import { createSelector } from "reselect"; import { createSelector } from "reselect";
import { import {
selectClaimsByUri, selectClaimsByUri,
selectClaimListMineIsPending, selectIsFetchingClaimListMine,
selectMyClaimsOutpoints, selectMyClaimsOutpoints,
} from "selectors/claims"; } from "selectors/claims";
@ -13,16 +13,16 @@ export const selectFileInfosByOutpoint = createSelector(
state => state.byOutpoint || {} state => state.byOutpoint || {}
); );
export const selectFileListIsPending = createSelector( export const selectIsFetchingFileList = createSelector(
_selectState, _selectState,
state => state.isFileListPending state => !!state.isFetchingFileList
); );
export const selectFileListDownloadedOrPublishedIsPending = createSelector( export const selectIsFetchingFileListDownloadedOrPublished = createSelector(
selectFileListIsPending, selectIsFetchingFileList,
selectClaimListMineIsPending, selectIsFetchingClaimListMine,
(isFileListPending, isClaimListMinePending) => (isFetchingFileList, isFetchingClaimListMine) =>
isFileListPending || isClaimListMinePending isFetchingFileList || isFetchingClaimListMine
); );
export const selectFileInfoForUri = (state, props) => { export const selectFileInfoForUri = (state, props) => {