mirror of
https://github.com/LBRYFoundation/lbry-desktop.git
synced 2025-08-31 01:11:26 +00:00
use lbryinc/lbry-redux for rewards/featured content
This commit is contained in:
parent
9b66553c61
commit
4dbd364ea1
5 changed files with 9 additions and 80 deletions
|
@ -1,6 +1,10 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { selectUnclaimedRewardValue, selectFetchingRewards, doRewardList } from 'lbryinc';
|
import {
|
||||||
import { doFetchRewardedContent } from 'redux/actions/content';
|
selectUnclaimedRewardValue,
|
||||||
|
selectFetchingRewards,
|
||||||
|
doRewardList,
|
||||||
|
doFetchRewardedContent,
|
||||||
|
} from 'lbryinc';
|
||||||
import RewardSummary from './view';
|
import RewardSummary from './view';
|
||||||
|
|
||||||
const select = state => ({
|
const select = state => ({
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { doFetchFeaturedUris, doFetchRewardedContent } from 'redux/actions/content';
|
import { selectFeaturedUris, selectFetchingFeaturedUris, doFetchFeaturedUris } from 'lbry-redux';
|
||||||
import { selectFeaturedUris, selectFetchingFeaturedUris } from 'redux/selectors/content';
|
import { doFetchRewardedContent } from 'lbryinc';
|
||||||
import DiscoverPage from './view';
|
import DiscoverPage from './view';
|
||||||
|
|
||||||
const select = state => ({
|
const select = state => ({
|
||||||
|
|
|
@ -13,7 +13,6 @@ import {
|
||||||
doHideNotification,
|
doHideNotification,
|
||||||
} from 'lbry-redux';
|
} from 'lbry-redux';
|
||||||
import Native from 'native';
|
import Native from 'native';
|
||||||
import { doFetchRewardedContent } from 'redux/actions/content';
|
|
||||||
import { doFetchDaemonSettings } from 'redux/actions/settings';
|
import { doFetchDaemonSettings } from 'redux/actions/settings';
|
||||||
import { doAuthNavigate } from 'redux/actions/navigation';
|
import { doAuthNavigate } from 'redux/actions/navigation';
|
||||||
import { doCheckSubscriptionsInit } from 'redux/actions/subscriptions';
|
import { doCheckSubscriptionsInit } from 'redux/actions/subscriptions';
|
||||||
|
@ -27,7 +26,7 @@ import {
|
||||||
selectRemoteVersion,
|
selectRemoteVersion,
|
||||||
selectUpgradeTimer,
|
selectUpgradeTimer,
|
||||||
} from 'redux/selectors/app';
|
} from 'redux/selectors/app';
|
||||||
import { doAuthenticate } from 'lbryinc';
|
import { doAuthenticate, doFetchRewardedContent } from 'lbryinc';
|
||||||
import { lbrySettings as config, version as appVersion } from 'package.json';
|
import { lbrySettings as config, version as appVersion } from 'package.json';
|
||||||
|
|
||||||
const { autoUpdater } = remote.require('electron-updater');
|
const { autoUpdater } = remote.require('electron-updater');
|
||||||
|
|
|
@ -15,8 +15,6 @@ import {
|
||||||
Lbry,
|
Lbry,
|
||||||
Lbryapi,
|
Lbryapi,
|
||||||
buildURI,
|
buildURI,
|
||||||
batchActions,
|
|
||||||
doResolveUris,
|
|
||||||
doFetchClaimListMine,
|
doFetchClaimListMine,
|
||||||
makeSelectCostInfoForUri,
|
makeSelectCostInfoForUri,
|
||||||
makeSelectFileInfoForUri,
|
makeSelectFileInfoForUri,
|
||||||
|
@ -30,74 +28,9 @@ import { makeSelectClientSetting, selectosNotificationsEnabled } from 'redux/sel
|
||||||
import setBadge from 'util/setBadge';
|
import setBadge from 'util/setBadge';
|
||||||
import setProgressBar from 'util/setProgressBar';
|
import setProgressBar from 'util/setProgressBar';
|
||||||
import analytics from 'analytics';
|
import analytics from 'analytics';
|
||||||
import { Lbryio } from 'lbryinc';
|
|
||||||
|
|
||||||
const DOWNLOAD_POLL_INTERVAL = 250;
|
const DOWNLOAD_POLL_INTERVAL = 250;
|
||||||
|
|
||||||
export function doFetchFeaturedUris() {
|
|
||||||
return dispatch => {
|
|
||||||
dispatch({
|
|
||||||
type: ACTIONS.FETCH_FEATURED_CONTENT_STARTED,
|
|
||||||
});
|
|
||||||
|
|
||||||
const success = ({ Uris }) => {
|
|
||||||
const urisToResolve = Object.keys(Uris).reduce(
|
|
||||||
(resolve, category) => [...resolve, ...Uris[category]],
|
|
||||||
[]
|
|
||||||
);
|
|
||||||
|
|
||||||
const actions = [
|
|
||||||
doResolveUris(urisToResolve),
|
|
||||||
{
|
|
||||||
type: ACTIONS.FETCH_FEATURED_CONTENT_COMPLETED,
|
|
||||||
data: {
|
|
||||||
uris: Uris,
|
|
||||||
success: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
];
|
|
||||||
dispatch(batchActions(...actions));
|
|
||||||
};
|
|
||||||
|
|
||||||
const failure = () => {
|
|
||||||
dispatch({
|
|
||||||
type: ACTIONS.FETCH_FEATURED_CONTENT_COMPLETED,
|
|
||||||
data: {
|
|
||||||
uris: {},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
Lbryio.call('file', 'list_homepage').then(success, failure);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function doFetchRewardedContent() {
|
|
||||||
return dispatch => {
|
|
||||||
const success = nameToClaimId => {
|
|
||||||
dispatch({
|
|
||||||
type: ACTIONS.FETCH_REWARD_CONTENT_COMPLETED,
|
|
||||||
data: {
|
|
||||||
claimIds: Object.values(nameToClaimId),
|
|
||||||
success: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const failure = () => {
|
|
||||||
dispatch({
|
|
||||||
type: ACTIONS.FETCH_REWARD_CONTENT_COMPLETED,
|
|
||||||
data: {
|
|
||||||
claimIds: [],
|
|
||||||
success: false,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
Lbryio.call('reward', 'list_featured').then(success, failure);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function doUpdateLoadStatus(uri, outpoint) {
|
export function doUpdateLoadStatus(uri, outpoint) {
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
Lbry.file_list({
|
Lbry.file_list({
|
||||||
|
|
|
@ -4,13 +4,6 @@ import { HISTORY_ITEMS_PER_PAGE } from 'constants/content';
|
||||||
|
|
||||||
export const selectState = state => state.content || {};
|
export const selectState = state => state.content || {};
|
||||||
|
|
||||||
export const selectFeaturedUris = createSelector(selectState, state => state.featuredUris);
|
|
||||||
|
|
||||||
export const selectFetchingFeaturedUris = createSelector(
|
|
||||||
selectState,
|
|
||||||
state => state.fetchingFeaturedContent
|
|
||||||
);
|
|
||||||
|
|
||||||
export const selectPlayingUri = createSelector(selectState, state => state.playingUri);
|
export const selectPlayingUri = createSelector(selectState, state => state.playingUri);
|
||||||
|
|
||||||
export const selectChannelClaimCounts = createSelector(
|
export const selectChannelClaimCounts = createSelector(
|
||||||
|
|
Loading…
Add table
Reference in a new issue