lbry-desktop/ui/js/selectors/content.js

45 lines
1.1 KiB
JavaScript
Raw Normal View History

2017-06-06 17:19:12 -04:00
import { createSelector } from "reselect";
2017-04-23 16:56:50 +07:00
2017-06-05 21:21:55 -07:00
export const _selectState = state => state.content || {};
2017-04-23 16:56:50 +07:00
2017-05-03 23:44:08 -04:00
export const selectFeaturedUris = createSelector(
2017-04-23 16:56:50 +07:00
_selectState,
2017-06-06 17:19:12 -04:00
state => state.featuredUris
2017-06-05 21:21:55 -07:00
);
2017-04-23 16:56:50 +07:00
2017-05-03 23:44:08 -04:00
export const selectFetchingFeaturedUris = createSelector(
2017-04-23 16:56:50 +07:00
_selectState,
2017-06-06 17:19:12 -04:00
state => !!state.fetchingFeaturedContent
2017-06-05 21:21:55 -07:00
);
2017-04-23 16:56:50 +07:00
2017-05-15 12:34:33 -04:00
export const selectResolvingUris = createSelector(
2017-05-02 11:48:16 +07:00
_selectState,
2017-06-06 17:19:12 -04:00
state => state.resolvingUris || []
2017-06-05 21:21:55 -07:00
);
2017-05-02 11:48:16 +07:00
const selectResolvingUri = (state, props) => {
2017-06-06 17:19:12 -04:00
return selectResolvingUris(state).indexOf(props.uri) != -1;
2017-06-05 21:21:55 -07:00
};
2017-05-02 11:48:16 +07:00
2017-05-14 23:50:59 -04:00
export const makeSelectIsResolvingForUri = () => {
2017-06-06 17:19:12 -04:00
return createSelector(selectResolvingUri, resolving => resolving);
2017-06-05 21:21:55 -07:00
};
2017-07-17 13:06:04 +07:00
export const selectChannelPages = createSelector(
_selectState,
state => state.channelPages || {}
);
const selectTotalPagesForChannel = (state, props) => {
return selectChannelPages(state)[props.uri];
};
export const makeSelectTotalPagesForChannel = () => {
return createSelector(selectTotalPagesForChannel, totalPages => totalPages);
};
2017-07-29 18:56:08 -04:00
export const selectRewardContentClaimIds = createSelector(
_selectState,
2017-07-29 18:56:08 -04:00
state => state.rewardedContentClaimIds
);