diff --git a/ui/js/actions/content.js b/ui/js/actions/content.js index 695cbd6ee..9735434be 100644 --- a/ui/js/actions/content.js +++ b/ui/js/actions/content.js @@ -133,6 +133,34 @@ export function doFetchFeaturedUris() { }; } +export function doFetchHotRightNowContent() { + return function(dispatch, getState) { + const state = getState(); + + const success = nameToClaimId => { + dispatch({ + type: types.FETCH_HOT_RIGHT_NOW_CONTENT_COMPLETED, + data: { + claimIds: Object.values(nameToClaimId), + success: true, + }, + }); + }; + + const failure = () => { + dispatch({ + type: types.FETCH_HOT_RIGHT_NOW_CONTENT_COMPLETED, + data: { + claimIds: [], + success: false, + }, + }); + }; + + lbryio.call("reward", "list_featured").then(success, failure); + }; +} + export function doUpdateLoadStatus(uri, outpoint) { return function(dispatch, getState) { const state = getState(); diff --git a/ui/js/component/app/index.js b/ui/js/component/app/index.js index 41f79393e..bdc7420a1 100644 --- a/ui/js/component/app/index.js +++ b/ui/js/component/app/index.js @@ -7,6 +7,8 @@ import { doAlertError, doRecordScroll, } from "actions/app"; +import { doFetchHotRightNowContent } from "actions/content"; + import { doUpdateBalance } from "actions/wallet"; import { selectWelcomeModalAcknowledged } from "selectors/app"; import { selectUser } from "selectors/user"; @@ -24,6 +26,7 @@ const perform = dispatch => ({ checkUpgradeAvailable: () => dispatch(doCheckUpgradeAvailable()), openWelcomeModal: () => dispatch(doOpenModal(modals.WELCOME)), updateBalance: balance => dispatch(doUpdateBalance(balance)), + fetchHotRightNowContent: () => dispatch(doFetchHotRightNowContent()), recordScroll: scrollPosition => dispatch(doRecordScroll(scrollPosition)), }); diff --git a/ui/js/component/app/view.jsx b/ui/js/component/app/view.jsx index 4d875dd54..24b898122 100644 --- a/ui/js/component/app/view.jsx +++ b/ui/js/component/app/view.jsx @@ -12,7 +12,12 @@ import * as modals from "constants/modal_types"; class App extends React.PureComponent { componentWillMount() { - const { alertError, checkUpgradeAvailable, updateBalance } = this.props; + const { + alertError, + checkUpgradeAvailable, + updateBalance, + fetchHotRightNowContent, + } = this.props; document.addEventListener("unhandledError", event => { alertError(event.detail); @@ -26,6 +31,8 @@ class App extends React.PureComponent { updateBalance(balance); }); + fetchHotRightNowContent(); + this.showWelcome(this.props); this.scrollListener = () => this.props.recordScroll(window.scrollY); diff --git a/ui/js/component/fileCard/index.js b/ui/js/component/fileCard/index.js index 65d162009..d47964175 100644 --- a/ui/js/component/fileCard/index.js +++ b/ui/js/component/fileCard/index.js @@ -8,7 +8,10 @@ import { makeSelectMetadataForUri, } from "selectors/claims"; import { makeSelectFileInfoForUri } from "selectors/file_info"; -import { makeSelectIsResolvingForUri } from "selectors/content"; +import { + makeSelectIsResolvingForUri, + selectHotRightNowClaimIds, +} from "selectors/content"; import FileCard from "./view"; const makeSelect = () => { @@ -22,6 +25,7 @@ const makeSelect = () => { fileInfo: selectFileInfoForUri(state, props), obscureNsfw: !selectShowNsfw(state), metadata: selectMetadataForUri(state, props), + hotRightNowClaimIds: selectHotRightNowClaimIds(state, props), isResolvingUri: selectResolvingUri(state, props), }); diff --git a/ui/js/component/fileCard/view.jsx b/ui/js/component/fileCard/view.jsx index cb57a4308..37e0be51c 100644 --- a/ui/js/component/fileCard/view.jsx +++ b/ui/js/component/fileCard/view.jsx @@ -46,7 +46,14 @@ class FileCard extends React.PureComponent { } render() { - const { claim, fileInfo, metadata, isResolvingUri, navigate } = this.props; + const { + claim, + fileInfo, + metadata, + isResolvingUri, + navigate, + hotRightNowClaimIds, + } = this.props; const uri = lbryuri.normalize(this.props.uri); const title = metadata && metadata.title ? metadata.title : uri; @@ -54,6 +61,7 @@ class FileCard extends React.PureComponent { ? metadata.thumbnail : null; const obscureNsfw = this.props.obscureNsfw && metadata && metadata.nsfw; + const isHotRightNow = claim && hotRightNowClaimIds.includes(claim.claim_id); let description = ""; if (isResolvingUri && !claim) { @@ -83,6 +91,7 @@ class FileCard extends React.PureComponent {