2020-11-02 11:51:08 -05:00
|
|
|
import { connect } from 'react-redux';
|
2021-10-07 23:47:39 -04:00
|
|
|
import { doResolveUri } from 'redux/actions/claims';
|
|
|
|
import { makeSelectClaimForUri } from 'redux/selectors/claims';
|
2022-06-08 18:11:05 -03:00
|
|
|
import { selectPrimaryUri, makeSelectContentWatchedPercentageForUri } from 'redux/selectors/content';
|
2017-12-21 18:08:54 -03:00
|
|
|
import CardMedia from './view';
|
2022-04-22 00:00:57 -03:00
|
|
|
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
|
|
|
import * as SETTINGS from 'constants/settings';
|
2017-07-14 00:18:28 +01:00
|
|
|
|
2022-04-22 00:00:57 -03:00
|
|
|
const select = (state, props) => {
|
2022-06-08 18:11:05 -03:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2022-04-22 00:00:57 -03:00
|
|
|
return {
|
|
|
|
watchedPercentage: makeSelectContentWatchedPercentageForUri(props.uri)(state),
|
|
|
|
claim: makeSelectClaimForUri(props.uri)(state),
|
2022-06-08 18:11:05 -03:00
|
|
|
showPercentage: !isBeingPlayed && makeSelectClientSetting(SETTINGS.PERSIST_WATCH_TIME)(state),
|
2022-04-22 00:00:57 -03:00
|
|
|
};
|
|
|
|
};
|
2020-11-02 11:51:08 -05:00
|
|
|
|
|
|
|
export default connect(select, { doResolveUri })(CardMedia);
|