3322b91c5d
Even with the caching changes, a 150kB thumbnail still takes 1-2s to fetch. This impacts the score. ## Change (1) Start with a large-enough placeholder image (has to be larger than the final image -- inflating doesn't count), then delay just enough for scoring, then switch to the real thumbnail. (2) Since we are now doing post-mount stuff, we have the exact dimensions to optimize the claim thumbnail. This reduces the typically-several-MBs thumbnail to kBs.
50 lines
2 KiB
JavaScript
50 lines
2 KiB
JavaScript
import { connect } from 'react-redux';
|
|
import { doPlayUri, doSetPlayingUri, doSetPrimaryUri } from 'redux/actions/content';
|
|
import {
|
|
makeSelectFileInfoForUri,
|
|
makeSelectThumbnailForUri,
|
|
makeSelectClaimForUri,
|
|
makeSelectStreamingUrlForUri,
|
|
makeSelectClaimWasPurchased,
|
|
SETTINGS,
|
|
} from 'lbry-redux';
|
|
import { makeSelectCostInfoForUri } from 'lbryinc';
|
|
import { selectUserVerifiedEmail } from 'redux/selectors/user';
|
|
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
|
import { withRouter } from 'react-router';
|
|
import {
|
|
makeSelectIsPlaying,
|
|
makeSelectShouldObscurePreview,
|
|
selectPlayingUri,
|
|
makeSelectInsufficientCreditsForUri,
|
|
makeSelectFileRenderModeForUri,
|
|
} from 'redux/selectors/content';
|
|
import FileRenderInitiator from './view';
|
|
import { doAnaltyicsPurchaseEvent } from 'redux/actions/app';
|
|
|
|
const select = (state, props) => ({
|
|
claimThumbnail: makeSelectThumbnailForUri(props.uri)(state),
|
|
fileInfo: makeSelectFileInfoForUri(props.uri)(state),
|
|
obscurePreview: makeSelectShouldObscurePreview(props.uri)(state),
|
|
isPlaying: makeSelectIsPlaying(props.uri)(state),
|
|
playingUri: selectPlayingUri(state),
|
|
insufficientCredits: makeSelectInsufficientCreditsForUri(props.uri)(state),
|
|
streamingUrl: makeSelectStreamingUrlForUri(props.uri)(state),
|
|
autoplay: makeSelectClientSetting(SETTINGS.AUTOPLAY)(state),
|
|
hasCostInfo: Boolean(makeSelectCostInfoForUri(props.uri)(state)),
|
|
costInfo: makeSelectCostInfoForUri(props.uri)(state),
|
|
renderMode: makeSelectFileRenderModeForUri(props.uri)(state),
|
|
claim: makeSelectClaimForUri(props.uri)(state),
|
|
claimWasPurchased: makeSelectClaimWasPurchased(props.uri)(state),
|
|
authenticated: selectUserVerifiedEmail(state),
|
|
});
|
|
|
|
const perform = (dispatch) => ({
|
|
play: (uri) => {
|
|
dispatch(doSetPrimaryUri(uri));
|
|
dispatch(doSetPlayingUri({ uri }));
|
|
dispatch(doPlayUri(uri, undefined, undefined, (fileInfo) => dispatch(doAnaltyicsPurchaseEvent(fileInfo))));
|
|
},
|
|
});
|
|
|
|
export default withRouter(connect(select, perform)(FileRenderInitiator));
|