lbry-desktop/ui/component/fileThumbnail/index.js

27 lines
1.1 KiB
JavaScript
Raw Permalink Normal View History

2020-11-02 17:51:08 +01:00
import { connect } from 'react-redux';
import { doResolveUri } from 'redux/actions/claims';
import { makeSelectClaimForUri } from 'redux/selectors/claims';
import { selectPrimaryUri, makeSelectContentWatchedPercentageForUri } from 'redux/selectors/content';
import CardMedia from './view';
import { makeSelectClientSetting } from 'redux/selectors/settings';
import * as SETTINGS from 'constants/settings';
2017-07-14 01:18:28 +02:00
const select = (state, props) => {
const claimUriBeingPlayed = selectPrimaryUri(state);
let isBeingPlayed = false;
if (claimUriBeingPlayed) {
const claim = makeSelectClaimForUri(props.uri)(state);
const claimBeingPlayed = makeSelectClaimForUri(claimUriBeingPlayed)(state);
isBeingPlayed = claim.claim_id === claimBeingPlayed.claim_id;
}
return {
watchedPercentage: makeSelectContentWatchedPercentageForUri(props.uri)(state),
claim: makeSelectClaimForUri(props.uri)(state),
showPercentage: !isBeingPlayed && makeSelectClientSetting(SETTINGS.PERSIST_WATCH_TIME)(state),
};
};
2020-11-02 17:51:08 +01:00
export default connect(select, { doResolveUri })(CardMedia);