Clean code
This commit is contained in:
parent
d3fc96d961
commit
7045f4ed45
2 changed files with 3 additions and 50 deletions
|
@ -1,30 +1,9 @@
|
|||
import { connect } from 'react-redux';
|
||||
|
||||
import { withRouter } from 'react-router-dom';
|
||||
import WatchHistoryPage from './view';
|
||||
import {
|
||||
selectTitleForUri,
|
||||
selectClaimIsMine,
|
||||
makeSelectClaimIsPending,
|
||||
makeSelectClaimForClaimId,
|
||||
makeSelectChannelForClaimUri,
|
||||
} from 'redux/selectors/claims';
|
||||
|
||||
import { makeSelectClaimForClaimId, makeSelectChannelForClaimUri } from 'redux/selectors/claims';
|
||||
import { selectHistory } from 'redux/selectors/content';
|
||||
|
||||
import { doClearContentHistoryAll } from 'redux/actions/content';
|
||||
|
||||
import {
|
||||
makeSelectCollectionForId,
|
||||
makeSelectUrlsForCollectionId,
|
||||
makeSelectIsResolvingCollectionForId,
|
||||
makeSelectCollectionIsMine,
|
||||
makeSelectCountForCollectionId,
|
||||
makeSelectEditedCollectionForId,
|
||||
} from 'redux/selectors/collections';
|
||||
|
||||
import { getThumbnailFromClaim } from 'util/claim';
|
||||
import { doFetchItemsInCollection, doCollectionDelete, doCollectionEdit } from 'redux/actions/collections';
|
||||
import { selectUser } from 'redux/selectors/user';
|
||||
|
||||
const select = (state, props) => {
|
||||
|
@ -36,19 +15,7 @@ const select = (state, props) => {
|
|||
const uri = (claim && (claim.canonical_url || claim.permanent_url)) || null;
|
||||
|
||||
return {
|
||||
collectionId,
|
||||
claim,
|
||||
collection: makeSelectCollectionForId(collectionId)(state),
|
||||
collectionUrls: makeSelectUrlsForCollectionId(collectionId)(state),
|
||||
collectionCount: makeSelectCountForCollectionId(collectionId)(state),
|
||||
isResolvingCollection: makeSelectIsResolvingCollectionForId(collectionId)(state),
|
||||
selectHistory: selectHistory(state, uri),
|
||||
title: selectTitleForUri(state, uri),
|
||||
thumbnail: getThumbnailFromClaim(claim),
|
||||
isMyClaim: selectClaimIsMine(state, claim), // or collection is mine?
|
||||
isMyCollection: makeSelectCollectionIsMine(collectionId)(state),
|
||||
claimIsPending: makeSelectClaimIsPending(uri)(state),
|
||||
collectionHasEdits: Boolean(makeSelectEditedCollectionForId(collectionId)(state)),
|
||||
uri,
|
||||
user: selectUser(state),
|
||||
channel: uri && makeSelectChannelForClaimUri(uri)(state),
|
||||
|
@ -57,9 +24,6 @@ const select = (state, props) => {
|
|||
|
||||
const perform = (dispatch) => ({
|
||||
doClearContentHistoryAll: () => dispatch(doClearContentHistoryAll()),
|
||||
fetchCollectionItems: (claimId, cb) => dispatch(doFetchItemsInCollection({ collectionId: claimId }, cb)), // if this collection is not resolved, resolve it
|
||||
deleteCollection: (id, colKey) => dispatch(doCollectionDelete(id, colKey)),
|
||||
editCollection: (id, params) => dispatch(doCollectionEdit(id, params)),
|
||||
});
|
||||
|
||||
export default withRouter(connect(select, perform)(WatchHistoryPage));
|
||||
|
|
|
@ -12,21 +12,12 @@ import Tooltip from 'component/common/tooltip';
|
|||
export const PAGE_VIEW_QUERY = 'view';
|
||||
|
||||
type Props = {
|
||||
collectionId: string,
|
||||
claim: Claim,
|
||||
title: string,
|
||||
thumbnail: string,
|
||||
collectionUrls: Array<string>,
|
||||
isResolvingCollection: boolean,
|
||||
selectHistory: Array<any>,
|
||||
doClearContentHistoryAll: () => void,
|
||||
fetchCollectionItems: (string, () => void) => void,
|
||||
resolveUris: (string) => void,
|
||||
user: ?User,
|
||||
};
|
||||
|
||||
export default function WatchHistoryPage(props: Props) {
|
||||
const { collectionId, selectHistory, doClearContentHistoryAll } = props;
|
||||
const { selectHistory, doClearContentHistoryAll } = props;
|
||||
const [watchHistory, setWatchHistory] = useState([]);
|
||||
const [unavailableUris] = React.useState([]);
|
||||
|
||||
|
@ -67,9 +58,7 @@ export default function WatchHistoryPage(props: Props) {
|
|||
)}
|
||||
</div>
|
||||
</div>
|
||||
{watchHistory.length > 0 && (
|
||||
<ClaimList uris={watchHistory} collectionId={collectionId} unavailableUris={unavailableUris} inWatchHistory />
|
||||
)}
|
||||
{watchHistory.length > 0 && <ClaimList uris={watchHistory} unavailableUris={unavailableUris} inWatchHistory />}
|
||||
{watchHistory.length === 0 && (
|
||||
<div style={{ textAlign: 'center' }}>
|
||||
<img src={YRBL_SAD_IMG_URL} />
|
||||
|
|
Loading…
Reference in a new issue