Add new selector for first item in related content #110
4 changed files with 79 additions and 64 deletions
|
@ -1,6 +1,5 @@
|
|||
{
|
||||
"trailingComma": "es5",
|
||||
"printWidth": 100,
|
||||
"singleQuote": true,
|
||||
"arrowParens": "always"
|
||||
"singleQuote": true
|
||||
}
|
||||
|
|
18
dist/bundle.js
vendored
18
dist/bundle.js
vendored
|
@ -89,8 +89,8 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.selectTransactionListFilter = exports.selectWalletUnlockResult = exports.selectWalletUnlockSucceeded = exports.selectWalletUnlockPending = exports.selectWalletDecryptResult = exports.selectWalletDecryptSucceeded = exports.selectWalletDecryptPending = exports.selectWalletEncryptResult = exports.selectWalletEncryptSucceeded = exports.selectWalletEncryptPending = exports.selectWalletState = exports.selectWalletIsEncrypted = exports.selectBlocks = exports.selectDraftTransactionError = exports.selectDraftTransactionAddress = exports.selectDraftTransactionAmount = exports.selectDraftTransaction = exports.selectGettingNewAddress = exports.selectReceiveAddress = exports.selectIsSendingSupport = exports.selectIsFetchingTransactions = exports.selectHasTransactions = exports.selectRecentTransactions = exports.selectTransactionItems = exports.selectTransactionsById = exports.selectBalance = exports.makeSelectBlockDate = exports.selectSearchSuggestions = exports.selectSearchBarFocused = exports.selectWunderBarAddress = exports.selectSearchUrisByQuery = exports.selectIsSearching = exports.selectSearchValue = exports.selectSearchQuery = exports.makeSelectSearchUris = exports.selectSearchState = exports.selectActiveHistoryEntry = exports.selectHistoryStack = exports.selectHistoryIndex = exports.selectIsForwardDisabled = exports.selectIsBackDisabled = exports.selectPathAfterAuth = exports.selectPageTitle = exports.selectHeaderLinks = exports.selectCurrentParams = exports.selectCurrentPage = exports.selectCurrentPath = exports.makeSelectCurrentParam = exports.computePageFromPath = exports.selectFileListPublishedSort = exports.selectFileListDownloadedSort = exports.selectSearchDownloadUris = exports.selectTotalDownloadProgress = exports.selectDownloadingFileInfos = exports.selectFileInfosDownloaded = exports.selectUrisLoading = exports.selectDownloadingByOutpoint = exports.selectIsFetchingFileListDownloadedOrPublished = exports.selectIsFetchingFileList = exports.selectFileInfosByOutpoint = exports.makeSelectLoadingForUri = exports.makeSelectDownloadingForUri = exports.makeSelectFileInfoForUri = exports.selectFetchingCostInfo = exports.selectCostForCurrentPageUri = exports.selectAllCostInfoByUri = exports.makeSelectCostInfoForUri = exports.makeSelectFetchingCostInfoForUri = exports.selectChannelClaimCounts = exports.selectPlayingUri = exports.selectFetchingTrendingUris = exports.selectTrendingUris = exports.selectFetchingFeaturedUris = exports.selectFeaturedUris = exports.selectResolvingUris = exports.selectMyChannelClaims = exports.selectFetchingMyChannels = exports.selectMyClaimsOutpoints = exports.selectAllMyClaimsByOutpoint = exports.selectMyClaimsWithoutChannels = exports.selectMyClaims = undefined;
|
||||
exports.selectPendingClaims = exports.selectIsFetchingClaimListMine = exports.selectAllFetchingChannelClaims = exports.selectMyActiveClaims = exports.selectAbandoningIds = exports.selectMyClaimsRaw = exports.selectAllClaimsByChannel = exports.selectClaimsByUri = exports.selectClaimsById = exports.selectPendingById = exports.makeSelectPendingByUri = exports.makeSelectClaimIsPending = exports.makeSelectChannelForClaimUri = exports.makeSelectRecommendedContentForUri = exports.makeSelectNsfwCountForChannel = exports.makeSelectNsfwCountFromUris = exports.makeSelectTotalPagesForChannel = exports.makeSelectTotalItemsForChannel = exports.makeSelectIsUriResolving = exports.makeSelectContentTypeForUri = exports.makeSelectTitleForUri = exports.makeSelectMetadataForUri = exports.makeSelectClaimsInChannelForPage = exports.makeSelectClaimsInChannelForCurrentPage = exports.makeSelectFetchingChannelClaims = exports.makeSelectClaimIsMine = exports.makeSelectClaimForUri = exports.selectError = exports.selectToast = exports.selectBlackListedOutpoints = exports.blacklistReducer = exports.walletReducer = exports.searchReducer = exports.notificationsReducer = exports.fileInfoReducer = exports.costInfoReducer = exports.claimsReducer = exports.creditsToString = exports.formatFullPrice = exports.formatCredits = exports.toQueryString = exports.parseQueryParams = exports.batchActions = exports.doUpdateBlockHeight = exports.doSetTransactionListFilter = exports.doWalletStatus = exports.doWalletUnlock = exports.doWalletDecrypt = exports.doWalletEncrypt = exports.doSendTip = exports.doSetDraftTransactionAddress = exports.doSetDraftTransactionAmount = exports.doSendDraftTransaction = exports.doCheckAddressIsMine = exports.doGetNewAddress = exports.doFetchBlock = exports.doFetchTransactions = exports.doBalanceSubscribe = exports.doUpdateBalance = exports.doBlackListedOutpointsSubscribe = exports.doBlurSearchInput = exports.doFocusSearchInput = exports.doUpdateSearchQuery = exports.doSearch = exports.doSetFileListSort = exports.doFetchFileInfosAndPublishedClaims = exports.doFileList = exports.doFetchFileInfo = exports.doFetchCostInfoForUri = exports.doFetchTrendingUris = exports.doFetchFeaturedUris = exports.doResolveUri = exports.doResolveUris = exports.doAbandonClaim = exports.doFetchClaimListMine = exports.doFetchClaimCountByChannel = exports.doFetchClaimsByChannel = exports.doDismissError = exports.doError = exports.doDismissToast = exports.doToast = exports.convertToShareLink = exports.isNameValid = exports.isURIClaimable = exports.isURIValid = exports.normalizeURI = exports.buildURI = exports.parseURI = exports.regexAddress = exports.regexInvalidURI = exports.Lbryapi = exports.Lbry = exports.PAGES = exports.SORT_OPTIONS = exports.TRANSACTIONS = exports.SETTINGS = exports.SEARCH_TYPES = exports.THUMBNAIL_STATUSES = exports.ACTIONS = exports.Toast = undefined;
|
||||
exports.selectTransactionListFilter = exports.selectWalletUnlockResult = exports.selectWalletUnlockSucceeded = exports.selectWalletUnlockPending = exports.selectWalletDecryptResult = exports.selectWalletDecryptSucceeded = exports.selectWalletDecryptPending = exports.selectWalletEncryptResult = exports.selectWalletEncryptSucceeded = exports.selectWalletEncryptPending = exports.selectWalletState = exports.selectWalletIsEncrypted = exports.selectBlocks = exports.selectDraftTransactionError = exports.selectDraftTransactionAddress = exports.selectDraftTransactionAmount = exports.selectDraftTransaction = exports.selectGettingNewAddress = exports.selectReceiveAddress = exports.selectIsSendingSupport = exports.selectIsFetchingTransactions = exports.selectHasTransactions = exports.selectRecentTransactions = exports.selectTransactionItems = exports.selectTransactionsById = exports.selectBalance = exports.makeSelectBlockDate = exports.selectSearchSuggestions = exports.selectSearchBarFocused = exports.selectWunderBarAddress = exports.selectSearchUrisByQuery = exports.selectIsSearching = exports.selectSearchValue = exports.selectSearchQuery = exports.makeSelectSearchUris = exports.selectSearchState = exports.selectActiveHistoryEntry = exports.selectHistoryStack = exports.selectHistoryIndex = exports.selectIsForwardDisabled = exports.selectIsBackDisabled = exports.selectPathAfterAuth = exports.selectPageTitle = exports.selectHeaderLinks = exports.selectCurrentParams = exports.selectCurrentPage = exports.selectCurrentPath = exports.makeSelectCurrentParam = exports.computePageFromPath = exports.selectFileListPublishedSort = exports.selectFileListDownloadedSort = exports.selectSearchDownloadUris = exports.selectTotalDownloadProgress = exports.selectDownloadingFileInfos = exports.selectFileInfosDownloaded = exports.selectUrisLoading = exports.selectDownloadingByOutpoint = exports.selectIsFetchingFileListDownloadedOrPublished = exports.selectIsFetchingFileList = exports.selectFileInfosByOutpoint = exports.makeSelectLoadingForUri = exports.makeSelectDownloadingForUri = exports.makeSelectFileInfoForUri = exports.selectFetchingCostInfo = exports.selectCostForCurrentPageUri = exports.selectAllCostInfoByUri = exports.makeSelectCostInfoForUri = exports.makeSelectFetchingCostInfoForUri = exports.selectChannelClaimCounts = exports.selectPlayingUri = exports.selectFetchingTrendingUris = exports.selectTrendingUris = exports.selectFetchingFeaturedUris = exports.selectFeaturedUris = exports.selectResolvingUris = exports.selectMyChannelClaims = exports.selectFetchingMyChannels = exports.selectMyClaimsOutpoints = exports.selectAllMyClaimsByOutpoint = exports.selectMyClaimsWithoutChannels = exports.selectMyClaims = exports.selectPendingClaims = undefined;
|
||||
exports.selectIsFetchingClaimListMine = exports.selectAllFetchingChannelClaims = exports.selectMyActiveClaims = exports.selectAbandoningIds = exports.selectMyClaimsRaw = exports.selectAllClaimsByChannel = exports.selectClaimsByUri = exports.selectClaimsById = exports.selectPendingById = exports.makeSelectPendingByUri = exports.makeSelectClaimIsPending = exports.makeSelectChannelForClaimUri = exports.makeSelectFirstRecommendedFileForUri = exports.makeSelectRecommendedContentForUri = exports.makeSelectNsfwCountForChannel = exports.makeSelectNsfwCountFromUris = exports.makeSelectTotalPagesForChannel = exports.makeSelectTotalItemsForChannel = exports.makeSelectIsUriResolving = exports.makeSelectContentTypeForUri = exports.makeSelectTitleForUri = exports.makeSelectMetadataForUri = exports.makeSelectClaimsInChannelForPage = exports.makeSelectClaimsInChannelForCurrentPage = exports.makeSelectFetchingChannelClaims = exports.makeSelectClaimIsMine = exports.makeSelectClaimForUri = exports.selectError = exports.selectToast = exports.selectBlackListedOutpoints = exports.blacklistReducer = exports.walletReducer = exports.searchReducer = exports.notificationsReducer = exports.fileInfoReducer = exports.costInfoReducer = exports.claimsReducer = exports.creditsToString = exports.formatFullPrice = exports.formatCredits = exports.toQueryString = exports.parseQueryParams = exports.batchActions = exports.doUpdateBlockHeight = exports.doSetTransactionListFilter = exports.doWalletStatus = exports.doWalletUnlock = exports.doWalletDecrypt = exports.doWalletEncrypt = exports.doSendTip = exports.doSetDraftTransactionAddress = exports.doSetDraftTransactionAmount = exports.doSendDraftTransaction = exports.doCheckAddressIsMine = exports.doGetNewAddress = exports.doFetchBlock = exports.doFetchTransactions = exports.doBalanceSubscribe = exports.doUpdateBalance = exports.doBlackListedOutpointsSubscribe = exports.doBlurSearchInput = exports.doFocusSearchInput = exports.doUpdateSearchQuery = exports.doSearch = exports.doSetFileListSort = exports.doFetchFileInfosAndPublishedClaims = exports.doFileList = exports.doFetchFileInfo = exports.doFetchCostInfoForUri = exports.doFetchTrendingUris = exports.doFetchFeaturedUris = exports.doResolveUri = exports.doResolveUris = exports.doAbandonClaim = exports.doFetchClaimListMine = exports.doFetchClaimCountByChannel = exports.doFetchClaimsByChannel = exports.doDismissError = exports.doError = exports.doDismissToast = exports.doToast = exports.convertToShareLink = exports.isNameValid = exports.isURIClaimable = exports.isURIValid = exports.normalizeURI = exports.buildURI = exports.parseURI = exports.regexAddress = exports.regexInvalidURI = exports.Lbryapi = exports.Lbry = exports.PAGES = exports.SORT_OPTIONS = exports.TRANSACTIONS = exports.SETTINGS = exports.SEARCH_TYPES = exports.THUMBNAIL_STATUSES = exports.ACTIONS = exports.Toast = undefined;
|
||||
|
||||
var _Notification = __webpack_require__(1);
|
||||
|
||||
|
@ -625,6 +625,12 @@ Object.defineProperty(exports, 'makeSelectRecommendedContentForUri', {
|
|||
return _claims3.makeSelectRecommendedContentForUri;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'makeSelectFirstRecommendedFileForUri', {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _claims3.makeSelectFirstRecommendedFileForUri;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'makeSelectChannelForClaimUri', {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
|
@ -3258,7 +3264,7 @@ var objectKeys = Object.keys || function (obj) {
|
|||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.makeSelectChannelForClaimUri = exports.makeSelectRecommendedContentForUri = exports.makeSelectNsfwCountForChannel = exports.makeSelectNsfwCountFromUris = exports.makeSelectTotalPagesForChannel = exports.makeSelectTotalItemsForChannel = exports.selectChannelClaimCounts = exports.selectPlayingUri = exports.selectFetchingTrendingUris = exports.selectTrendingUris = exports.selectFetchingFeaturedUris = exports.selectFeaturedUris = exports.makeSelectIsUriResolving = exports.selectResolvingUris = exports.selectMyChannelClaims = exports.selectFetchingMyChannels = exports.selectMyClaimsOutpoints = exports.selectAllMyClaimsByOutpoint = exports.selectMyClaimsWithoutChannels = exports.selectMyClaims = exports.selectIsFetchingClaimListMine = exports.makeSelectContentTypeForUri = exports.makeSelectTitleForUri = exports.makeSelectMetadataForUri = exports.makeSelectClaimsInChannelForCurrentPage = exports.makeSelectClaimsInChannelForPage = exports.makeSelectFetchingChannelClaims = exports.selectAllFetchingChannelClaims = exports.makeSelectClaimIsMine = exports.selectMyActiveClaims = exports.selectAbandoningIds = exports.selectMyClaimsRaw = exports.makeSelectClaimForUri = exports.makeSelectPendingByUri = exports.makeSelectClaimIsPending = exports.selectPendingClaims = exports.selectPendingById = exports.selectAllClaimsByChannel = exports.selectClaimsByUri = exports.selectClaimsById = undefined;
|
||||
exports.makeSelectChannelForClaimUri = exports.makeSelectFirstRecommendedFileForUri = exports.makeSelectRecommendedContentForUri = exports.makeSelectNsfwCountForChannel = exports.makeSelectNsfwCountFromUris = exports.makeSelectTotalPagesForChannel = exports.makeSelectTotalItemsForChannel = exports.selectChannelClaimCounts = exports.selectPlayingUri = exports.selectFetchingTrendingUris = exports.selectTrendingUris = exports.selectFetchingFeaturedUris = exports.selectFeaturedUris = exports.makeSelectIsUriResolving = exports.selectResolvingUris = exports.selectMyChannelClaims = exports.selectFetchingMyChannels = exports.selectMyClaimsOutpoints = exports.selectAllMyClaimsByOutpoint = exports.selectMyClaimsWithoutChannels = exports.selectMyClaims = exports.selectIsFetchingClaimListMine = exports.makeSelectContentTypeForUri = exports.makeSelectTitleForUri = exports.makeSelectMetadataForUri = exports.makeSelectClaimsInChannelForCurrentPage = exports.makeSelectClaimsInChannelForPage = exports.makeSelectFetchingChannelClaims = exports.selectAllFetchingChannelClaims = exports.makeSelectClaimIsMine = exports.selectMyActiveClaims = exports.selectAbandoningIds = exports.selectMyClaimsRaw = exports.makeSelectClaimForUri = exports.makeSelectPendingByUri = exports.makeSelectClaimIsPending = exports.selectPendingClaims = exports.selectPendingById = exports.selectAllClaimsByChannel = exports.selectClaimsByUri = exports.selectClaimsById = undefined;
|
||||
|
||||
var _lbryURI = __webpack_require__(3);
|
||||
|
||||
|
@ -3587,6 +3593,12 @@ var makeSelectRecommendedContentForUri = exports.makeSelectRecommendedContentFor
|
|||
});
|
||||
};
|
||||
|
||||
var makeSelectFirstRecommendedFileForUri = exports.makeSelectFirstRecommendedFileForUri = function makeSelectFirstRecommendedFileForUri(uri) {
|
||||
return (0, _reselect.createSelector)(makeSelectRecommendedContentForUri(uri), function (recommendedContent) {
|
||||
return recommendedContent ? recommendedContent[0] : null;
|
||||
});
|
||||
};
|
||||
|
||||
// Returns the associated channel uri for a given claim uri
|
||||
var makeSelectChannelForClaimUri = exports.makeSelectChannelForClaimUri = function makeSelectChannelForClaimUri(uri) {
|
||||
var includePrefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
||||
|
|
|
@ -115,6 +115,7 @@ export {
|
|||
makeSelectNsfwCountFromUris,
|
||||
makeSelectNsfwCountForChannel,
|
||||
makeSelectRecommendedContentForUri,
|
||||
makeSelectFirstRecommendedFileForUri,
|
||||
makeSelectChannelForClaimUri,
|
||||
makeSelectClaimIsPending,
|
||||
makeSelectPendingByUri,
|
||||
|
|
|
@ -4,15 +4,15 @@ import { selectSearchUrisByQuery } from 'redux/selectors/search';
|
|||
import { createSelector } from 'reselect';
|
||||
import { isClaimNsfw } from 'util/claim';
|
||||
|
||||
const selectState = (state) => state.claims || {};
|
||||
const selectState = state => state.claims || {};
|
||||
|
||||
|
||||
export const selectClaimsById = createSelector(selectState, (state) => state.byId || {});
|
||||
export const selectClaimsById = createSelector(selectState, state => state.byId || {});
|
||||
|
||||
export const selectClaimsByUri = createSelector(selectState, selectClaimsById, (state, byId) => {
|
||||
const byUri = state.claimsByUri || {};
|
||||
const claims = {};
|
||||
|
||||
Object.keys(byUri).forEach((uri) => {
|
||||
Object.keys(byUri).forEach(uri => {
|
||||
const claimId = byUri[uri];
|
||||
|
||||
// NOTE returning a null claim allows us to differentiate between an
|
||||
|
@ -30,28 +30,28 @@ export const selectClaimsByUri = createSelector(selectState, selectClaimsById, (
|
|||
|
||||
export const selectAllClaimsByChannel = createSelector(
|
||||
selectState,
|
||||
(state) => state.claimsByChannel || {}
|
||||
state => state.claimsByChannel || {}
|
||||
);
|
||||
|
||||
export const selectPendingById = createSelector(selectState, (state) => state.pendingById || {});
|
||||
export const selectPendingById = createSelector(selectState, state => state.pendingById || {});
|
||||
|
||||
export const selectPendingClaims = createSelector(selectState, (state) =>
|
||||
export const selectPendingClaims = createSelector(selectState, state =>
|
||||
Object.values(state.pendingById || [])
|
||||
);
|
||||
|
||||
export const makeSelectClaimIsPending = (uri) =>
|
||||
createSelector(selectPendingById, (pendingById) => {
|
||||
export const makeSelectClaimIsPending = uri =>
|
||||
createSelector(selectPendingById, pendingById => {
|
||||
const { claimId } = parseURI(uri);
|
||||
return Boolean(pendingById[claimId]);
|
||||
});
|
||||
|
||||
export const makeSelectPendingByUri = (uri) =>
|
||||
createSelector(selectPendingById, (pendingById) => {
|
||||
export const makeSelectPendingByUri = uri =>
|
||||
createSelector(selectPendingById, pendingById => {
|
||||
const { claimId } = parseURI(uri);
|
||||
return pendingById[claimId];
|
||||
});
|
||||
|
||||
export const makeSelectClaimForUri = (uri) =>
|
||||
export const makeSelectClaimForUri = uri =>
|
||||
createSelector(selectClaimsByUri, selectPendingById, (byUri, pendingById) => {
|
||||
// Check if a claim is pending first
|
||||
// It won't be in claimsByUri because resolving it will return nothing
|
||||
|
@ -64,9 +64,9 @@ export const makeSelectClaimForUri = (uri) =>
|
|||
return byUri && byUri[normalizeURI(uri)];
|
||||
});
|
||||
|
||||
export const selectMyClaimsRaw = createSelector(selectState, (state) => state.myClaims);
|
||||
export const selectMyClaimsRaw = createSelector(selectState, state => state.myClaims);
|
||||
|
||||
export const selectAbandoningIds = createSelector(selectState, (state) =>
|
||||
export const selectAbandoningIds = createSelector(selectState, state =>
|
||||
Object.keys(state.abandoningById || {})
|
||||
);
|
||||
|
||||
|
@ -77,12 +77,12 @@ export const selectMyActiveClaims = createSelector(
|
|||
new Set(
|
||||
claims &&
|
||||
claims
|
||||
.map((claim) => claim.claim_id)
|
||||
.filter((claimId) => Object.keys(abandoningIds).indexOf(claimId) === -1)
|
||||
.map(claim => claim.claim_id)
|
||||
.filter(claimId => Object.keys(abandoningIds).indexOf(claimId) === -1)
|
||||
)
|
||||
);
|
||||
|
||||
export const makeSelectClaimIsMine = (rawUri) => {
|
||||
export const makeSelectClaimIsMine = rawUri => {
|
||||
const uri = normalizeURI(rawUri);
|
||||
return createSelector(
|
||||
selectClaimsByUri,
|
||||
|
@ -94,11 +94,11 @@ export const makeSelectClaimIsMine = (rawUri) => {
|
|||
|
||||
export const selectAllFetchingChannelClaims = createSelector(
|
||||
selectState,
|
||||
(state) => state.fetchingChannelClaims || {}
|
||||
state => state.fetchingChannelClaims || {}
|
||||
);
|
||||
|
||||
export const makeSelectFetchingChannelClaims = (uri) =>
|
||||
createSelector(selectAllFetchingChannelClaims, (fetching) => fetching && fetching[uri]);
|
||||
export const makeSelectFetchingChannelClaims = uri =>
|
||||
createSelector(selectAllFetchingChannelClaims, fetching => fetching && fetching[uri]);
|
||||
|
||||
export const makeSelectClaimsInChannelForPage = (uri, page) =>
|
||||
createSelector(selectClaimsById, selectAllClaimsByChannel, (byId, allClaims) => {
|
||||
|
@ -107,10 +107,10 @@ export const makeSelectClaimsInChannelForPage = (uri, page) =>
|
|||
|
||||
if (!claimIds) return claimIds;
|
||||
|
||||
return claimIds.map((claimId) => byId[claimId]);
|
||||
return claimIds.map(claimId => byId[claimId]);
|
||||
});
|
||||
|
||||
export const makeSelectClaimsInChannelForCurrentPage = (uri) => {
|
||||
export const makeSelectClaimsInChannelForCurrentPage = uri => {
|
||||
const pageSelector = makeSelectCurrentParam('page');
|
||||
|
||||
return createSelector(
|
||||
|
@ -123,30 +123,30 @@ export const makeSelectClaimsInChannelForCurrentPage = (uri) => {
|
|||
|
||||
if (!claimIds) return claimIds;
|
||||
|
||||
return claimIds.map((claimId) => byId[claimId]);
|
||||
return claimIds.map(claimId => byId[claimId]);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
export const makeSelectMetadataForUri = (uri) =>
|
||||
createSelector(makeSelectClaimForUri(uri), (claim) => {
|
||||
export const makeSelectMetadataForUri = uri =>
|
||||
createSelector(makeSelectClaimForUri(uri), claim => {
|
||||
const metadata = claim && claim.value && claim.value.stream && claim.value.stream.metadata;
|
||||
|
||||
return metadata || (claim === undefined ? undefined : null);
|
||||
});
|
||||
|
||||
export const makeSelectTitleForUri = (uri) =>
|
||||
createSelector(makeSelectMetadataForUri(uri), (metadata) => metadata && metadata.title);
|
||||
export const makeSelectTitleForUri = uri =>
|
||||
createSelector(makeSelectMetadataForUri(uri), metadata => metadata && metadata.title);
|
||||
|
||||
export const makeSelectContentTypeForUri = (uri) =>
|
||||
createSelector(makeSelectClaimForUri(uri), (claim) => {
|
||||
export const makeSelectContentTypeForUri = uri =>
|
||||
createSelector(makeSelectClaimForUri(uri), claim => {
|
||||
const source = claim && claim.value && claim.value.stream && claim.value.stream.source;
|
||||
return source ? source.contentType : undefined;
|
||||
});
|
||||
|
||||
export const selectIsFetchingClaimListMine = createSelector(
|
||||
selectState,
|
||||
(state) => state.isFetchingClaimListMine
|
||||
state => state.isFetchingClaimListMine
|
||||
);
|
||||
|
||||
export const selectMyClaims = createSelector(
|
||||
|
@ -157,7 +157,7 @@ export const selectMyClaims = createSelector(
|
|||
(myClaimIds, byId, abandoningIds, pendingClaims) => {
|
||||
const claims = [];
|
||||
|
||||
myClaimIds.forEach((id) => {
|
||||
myClaimIds.forEach(id => {
|
||||
const claim = byId[id];
|
||||
|
||||
if (claim && abandoningIds.indexOf(id) === -1) claims.push(claim);
|
||||
|
@ -167,27 +167,27 @@ export const selectMyClaims = createSelector(
|
|||
}
|
||||
);
|
||||
|
||||
export const selectMyClaimsWithoutChannels = createSelector(selectMyClaims, (myClaims) =>
|
||||
myClaims.filter((claim) => !claim.name.match(/^@/))
|
||||
export const selectMyClaimsWithoutChannels = createSelector(selectMyClaims, myClaims =>
|
||||
myClaims.filter(claim => !claim.name.match(/^@/))
|
||||
);
|
||||
|
||||
export const selectAllMyClaimsByOutpoint = createSelector(
|
||||
selectMyClaimsRaw,
|
||||
(claims) =>
|
||||
new Set(claims && claims.length ? claims.map((claim) => `${claim.txid}:${claim.nout}`) : null)
|
||||
claims =>
|
||||
new Set(claims && claims.length ? claims.map(claim => `${claim.txid}:${claim.nout}`) : null)
|
||||
);
|
||||
|
||||
export const selectMyClaimsOutpoints = createSelector(selectMyClaims, (myClaims) => {
|
||||
export const selectMyClaimsOutpoints = createSelector(selectMyClaims, myClaims => {
|
||||
const outpoints = [];
|
||||
|
||||
myClaims.forEach((claim) => outpoints.push(`${claim.txid}:${claim.nout}`));
|
||||
myClaims.forEach(claim => outpoints.push(`${claim.txid}:${claim.nout}`));
|
||||
|
||||
return outpoints;
|
||||
});
|
||||
|
||||
export const selectFetchingMyChannels = createSelector(
|
||||
selectState,
|
||||
(state) => state.fetchingMyChannels
|
||||
state => state.fetchingMyChannels
|
||||
);
|
||||
|
||||
export const selectMyChannelClaims = createSelector(
|
||||
|
@ -197,7 +197,7 @@ export const selectMyChannelClaims = createSelector(
|
|||
const ids = state.myChannelClaims || [];
|
||||
const claims = [];
|
||||
|
||||
ids.forEach((id) => {
|
||||
ids.forEach(id => {
|
||||
if (byId[id]) {
|
||||
// I'm not sure why this check is necessary, but it ought to be a quick fix for https://github.com/lbryio/lbry-desktop/issues/544
|
||||
claims.push(byId[id]);
|
||||
|
@ -208,49 +208,46 @@ export const selectMyChannelClaims = createSelector(
|
|||
}
|
||||
);
|
||||
|
||||
export const selectResolvingUris = createSelector(
|
||||
selectState,
|
||||
(state) => state.resolvingUris || []
|
||||
);
|
||||
export const selectResolvingUris = createSelector(selectState, state => state.resolvingUris || []);
|
||||
|
||||
export const makeSelectIsUriResolving = (uri) =>
|
||||
export const makeSelectIsUriResolving = uri =>
|
||||
createSelector(
|
||||
selectResolvingUris,
|
||||
(resolvingUris) => resolvingUris && resolvingUris.indexOf(uri) !== -1
|
||||
resolvingUris => resolvingUris && resolvingUris.indexOf(uri) !== -1
|
||||
);
|
||||
|
||||
export const selectFeaturedUris = createSelector(selectState, (state) => state.featuredUris);
|
||||
export const selectFeaturedUris = createSelector(selectState, state => state.featuredUris);
|
||||
|
||||
export const selectFetchingFeaturedUris = createSelector(
|
||||
selectState,
|
||||
(state) => state.fetchingFeaturedContent
|
||||
state => state.fetchingFeaturedContent
|
||||
);
|
||||
|
||||
export const selectTrendingUris = createSelector(selectState, (state) => state.trendingUris);
|
||||
export const selectTrendingUris = createSelector(selectState, state => state.trendingUris);
|
||||
|
||||
export const selectFetchingTrendingUris = createSelector(
|
||||
selectState,
|
||||
(state) => state.fetchingTrendingContent
|
||||
state => state.fetchingTrendingContent
|
||||
);
|
||||
|
||||
export const selectPlayingUri = createSelector(selectState, (state) => state.playingUri);
|
||||
export const selectPlayingUri = createSelector(selectState, state => state.playingUri);
|
||||
|
||||
export const selectChannelClaimCounts = createSelector(
|
||||
selectState,
|
||||
(state) => state.channelClaimCounts || {}
|
||||
state => state.channelClaimCounts || {}
|
||||
);
|
||||
|
||||
export const makeSelectTotalItemsForChannel = (uri) =>
|
||||
createSelector(selectChannelClaimCounts, (byUri) => byUri && byUri[uri]);
|
||||
export const makeSelectTotalItemsForChannel = uri =>
|
||||
createSelector(selectChannelClaimCounts, byUri => byUri && byUri[uri]);
|
||||
|
||||
export const makeSelectTotalPagesForChannel = (uri, pageSize = 10) =>
|
||||
createSelector(
|
||||
selectChannelClaimCounts,
|
||||
(byUri) => byUri && byUri[uri] && Math.ceil(byUri[uri] / pageSize)
|
||||
byUri => byUri && byUri[uri] && Math.ceil(byUri[uri] / pageSize)
|
||||
);
|
||||
|
||||
export const makeSelectNsfwCountFromUris = (uris) =>
|
||||
createSelector(selectClaimsByUri, (claims) =>
|
||||
export const makeSelectNsfwCountFromUris = uris =>
|
||||
createSelector(selectClaimsByUri, claims =>
|
||||
uris.reduce((acc, uri) => {
|
||||
const claim = claims[uri];
|
||||
if (isClaimNsfw(claim)) {
|
||||
|
@ -260,7 +257,7 @@ export const makeSelectNsfwCountFromUris = (uris) =>
|
|||
}, 0)
|
||||
);
|
||||
|
||||
export const makeSelectNsfwCountForChannel = (uri) => {
|
||||
export const makeSelectNsfwCountForChannel = uri => {
|
||||
const pageSelector = makeSelectCurrentParam('page');
|
||||
|
||||
return createSelector(
|
||||
|
@ -284,7 +281,7 @@ export const makeSelectNsfwCountForChannel = (uri) => {
|
|||
);
|
||||
};
|
||||
|
||||
export const makeSelectRecommendedContentForUri = (uri) =>
|
||||
export const makeSelectRecommendedContentForUri = uri =>
|
||||
createSelector(
|
||||
makeSelectClaimForUri(uri),
|
||||
selectSearchUrisByQuery,
|
||||
|
@ -302,7 +299,7 @@ export const makeSelectRecommendedContentForUri = (uri) =>
|
|||
|
||||
let searchUris = searchUrisByQuery[title.replace(/\//, ' ')];
|
||||
if (searchUris) {
|
||||
searchUris = searchUris.filter((searchUri) => searchUri !== currentUri);
|
||||
searchUris = searchUris.filter(searchUri => searchUri !== currentUri);
|
||||
recommendedContent = searchUris;
|
||||
}
|
||||
}
|
||||
|
@ -311,9 +308,15 @@ export const makeSelectRecommendedContentForUri = (uri) =>
|
|||
}
|
||||
);
|
||||
|
||||
export const makeSelectFirstRecommendedFileForUri = uri =>
|
||||
createSelector(
|
||||
makeSelectRecommendedContentForUri(uri),
|
||||
recommendedContent => (recommendedContent ? recommendedContent[0] : null)
|
||||
);
|
||||
|
||||
// Returns the associated channel uri for a given claim uri
|
||||
export const makeSelectChannelForClaimUri = (uri, includePrefix = false) =>
|
||||
createSelector(makeSelectClaimForUri(uri), (claim) => {
|
||||
createSelector(makeSelectClaimForUri(uri), claim => {
|
||||
if (!claim) {
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue
We added a prettier rule in this repo for this, but since we aren't using it in other projects, i removed it.