diff --git a/dist/bundle.es.js b/dist/bundle.es.js index cfade36..e2f4853 100644 --- a/dist/bundle.es.js +++ b/dist/bundle.es.js @@ -1190,6 +1190,7 @@ const Lbry = { utxo_release: (params = {}) => daemonCallWithResult('utxo_release', params), support_abandon: (params = {}) => daemonCallWithResult('support_abandon', params), purchase_list: (params = {}) => daemonCallWithResult('purchase_list', params), + txo_list: (params = {}) => daemonCallWithResult('txo_list', params), sync_hash: (params = {}) => daemonCallWithResult('sync_hash', params), sync_apply: (params = {}) => daemonCallWithResult('sync_apply', params), @@ -2370,7 +2371,13 @@ var _extends$3 = Object.assign || function (target) { for (var i = 1; i < argume const selectState$1 = state => state.claims || {}; -const selectClaimsById = reselect.createSelector(selectState$1, state => state.byId || {}); +const selectById = reselect.createSelector(selectState$1, state => state.byId || {}); + +const selectPendingClaimsById = reselect.createSelector(selectState$1, state => state.pendingById || {}); + +const selectClaimsById = reselect.createSelector(selectById, selectPendingClaimsById, (byId, pendingById) => { + return Object.assign(byId, pendingById); // do I need merged to keep metadata? +}); const selectClaimIdsByUri = reselect.createSelector(selectState$1, state => state.claimsByUri || {}); @@ -2405,21 +2412,21 @@ const selectClaimsByUri = reselect.createSelector(selectClaimIdsByUri, selectCla const selectAllClaimsByChannel = reselect.createSelector(selectState$1, state => state.paginatedClaimsByChannel || {}); -const selectPendingIds = reselect.createSelector(selectState$1, state => state.pendingIds || []); +const selectPendingIds = reselect.createSelector(selectState$1, state => Object.keys(state.pendingIds) || []); -const selectPendingClaims = reselect.createSelector(selectPendingIds, selectClaimsById, (pendingIds, byId) => pendingIds.map(id => byId[id])); +const selectPendingClaims = reselect.createSelector(selectPendingClaimsById, pendingById => Object.values(pendingById)); -const makeSelectClaimIsPending = uri => reselect.createSelector(selectClaimIdsByUri, selectPendingIds, (idsByUri, pendingIds) => { +const makeSelectClaimIsPending = uri => reselect.createSelector(selectClaimIdsByUri, selectPendingClaimsById, (idsByUri, pendingById) => { const claimId = idsByUri[normalizeURI(uri)]; if (claimId) { - return pendingIds.some(i => i === claimId); + return Boolean(pendingById[claimId]); } return false; }); -const makeSelectClaimIdIsPending = claimId => reselect.createSelector(selectPendingIds, pendingIds => { - return pendingIds.some(i => i === claimId); +const makeSelectClaimIdIsPending = claimId => reselect.createSelector(selectPendingClaimsById, pendingById => { + return Boolean(pendingById[claimId]); }); const makeSelectClaimIdForUri = uri => reselect.createSelector(selectClaimIdsByUri, claimIds => claimIds[uri]); @@ -2552,25 +2559,18 @@ const makeSelectClaimsInChannelForPage = (uri, page) => reselect.createSelector( return claimIds.map(claimId => byId[claimId]); }); +// THIS IS LEFT OVER FROM ONE TAB CHANNEL_CONTENT const makeSelectTotalClaimsInChannelSearch = uri => reselect.createSelector(selectClaimsById, selectAllClaimsByChannel, (byId, allClaims) => { const byChannel = allClaims[uri] || {}; return byChannel['itemCount']; }); +// THIS IS LEFT OVER FROM ONE_TAB CHANNEL CONTENT const makeSelectTotalPagesInChannelSearch = uri => reselect.createSelector(selectClaimsById, selectAllClaimsByChannel, (byId, allClaims) => { const byChannel = allClaims[uri] || {}; return byChannel['pageCount']; }); -const makeSelectClaimsInChannelForCurrentPageState = uri => reselect.createSelector(selectClaimsById, selectAllClaimsByChannel, selectCurrentChannelPage, (byId, allClaims, page) => { - const byChannel = allClaims[uri] || {}; - const claimIds = byChannel[page || 1]; - - if (!claimIds) return claimIds; - - return claimIds.map(claimId => byId[claimId]); -}); - const makeSelectMetadataForUri = uri => reselect.createSelector(makeSelectClaimForUri(uri), claim => { const metadata = claim && claim.value; return metadata || (claim === undefined ? undefined : null); @@ -2697,27 +2697,17 @@ const selectPlayingUri = reselect.createSelector(selectState$1, state => state.p const selectChannelClaimCounts = reselect.createSelector(selectState$1, state => state.channelClaimCounts || {}); -const makeSelectPendingClaimForUri = uri => reselect.createSelector(selectPendingIds, selectClaimsById, (pending, claims) => { - let uriIsChannel; +const makeSelectPendingClaimForUri = uri => reselect.createSelector(selectPendingClaimsById, pendingById => { let uriStreamName; let uriChannelName; try { - ({ - isChannel: uriIsChannel, - streamName: uriStreamName, - channelName: uriChannelName - } = parseURI(uri)); + ({ streamName: uriStreamName, channelName: uriChannelName } = parseURI(uri)); } catch (e) { return null; } - const pendingClaims = pending.map(id => claims[id]); + const pendingClaims = Object.values(pendingById); const matchingClaim = pendingClaims.find(claim => { - const { streamName, channelName, isChannel } = parseURI(claim.permanent_url); - if (isChannel) { - return channelName === uriChannelName; - } else { - return streamName === uriStreamName; - } + return claim.normalized_name === uriChannelName || claim.normalized_name === uriStreamName; }); return matchingClaim || null; }); @@ -2734,21 +2724,6 @@ const makeSelectNsfwCountFromUris = uris => reselect.createSelector(selectClaims return acc; }, 0)); -const makeSelectNsfwCountForChannel = uri => reselect.createSelector(selectClaimsById, selectAllClaimsByChannel, selectCurrentChannelPage, (byId, allClaims, page) => { - const byChannel = allClaims[uri] || {}; - const claimIds = byChannel[page || 1]; - - if (!claimIds) return 0; - - return claimIds.reduce((acc, claimId) => { - const claim = byId[claimId]; - if (isClaimNsfw(claim)) { - return acc + 1; - } - return acc; - }, 0); -}); - const makeSelectOmittedCountForChannel = uri => reselect.createSelector(makeSelectTotalItemsForChannel(uri), makeSelectTotalClaimsInChannelSearch(uri), (claimsInChannel, claimsInSearch) => { if (claimsInChannel && typeof claimsInSearch === 'number' && claimsInSearch >= 0) { return claimsInChannel - claimsInSearch; @@ -3690,7 +3665,7 @@ const makeSelectIsResolvingCollectionForId = id => reselect.createSelector(selec }); const makeSelectCollectionForId = id => reselect.createSelector(selectBuiltinCollections, selectResolvedCollections, selectMyUnpublishedCollections, selectMyEditedCollections, selectPendingCollections, (bLists, rLists, uLists, eLists, pLists) => { - const collection = bLists[id] || uLists[id] || eLists[id] || rLists[id] || pLists[id]; + const collection = bLists[id] || uLists[id] || eLists[id] || pLists[id] || rLists[id]; return collection; }); @@ -3748,6 +3723,9 @@ var _extends$5 = Object.assign || function (target) { for (var i = 1; i < argume function _asyncToGenerator$1(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } +let onChannelConfirmCallback; +let checkPendingInterval; + function doResolveUris(uris, returnCachedClaims = false, resolveReposts = true) { return (dispatch, getState) => { const normalizedUris = uris.map(normalizeURI); @@ -4086,7 +4064,7 @@ function doClearChannelErrors() { }; } -function doCreateChannel(name, amount, optionalParams, cb) { +function doCreateChannel(name, amount, optionalParams, onConfirm) { return dispatch => { dispatch({ type: CREATE_CHANNEL_STARTED @@ -4140,7 +4118,7 @@ function doCreateChannel(name, amount, optionalParams, cb) { claims: [channelClaim] } }); - dispatch(doCheckPendingClaims(cb)); + dispatch(doCheckPendingClaims(onConfirm)); return channelClaim; }).catch(error => { dispatch({ @@ -4490,7 +4468,6 @@ function doCollectionPublishUpdate(options) { } }); dispatch(doCheckPendingClaims()); - dispatch(doFetchCollectionListMine(1, 10)); return resolve(collectionClaim); } @@ -4570,48 +4547,63 @@ function doPurchaseList(page = 1, pageSize = PAGE_SIZE) { }; } -const doCheckPendingClaims = onConfirmed => (dispatch, getState) => { - let claimCheckInterval; - - const checkClaimList = () => { +const doCheckPendingClaims = onChannelConfirmed => (dispatch, getState) => { + if (onChannelConfirmed) { + onChannelConfirmCallback = onChannelConfirmed; + } + clearInterval(checkPendingInterval); + const checkTxoList = () => { const state = getState(); - const pendingIdSet = new Set(selectPendingIds(state)); + const pendingById = Object.assign({}, selectPendingClaimsById(state)); + const pendingTxos = Object.values(pendingById).map(p => p.txid); + // use collections const pendingCollections = selectPendingCollections(state); - lbryProxy.claim_list({ page: 1, page_size: 10 }).then(result => { - const claims = result.items; - const claimsToConfirm = []; - claims.forEach(claim => { - const { claim_id: claimId } = claim; - if (claim.confirmations > 0 && pendingIdSet.has(claimId)) { - pendingIdSet.delete(claimId); - if (Object.keys(pendingCollections).includes(claim.claim_id)) { - dispatch(doFetchItemsInCollection({ collectionId: claim.claim_id })); - dispatch(doCollectionDelete(claim.claim_id, 'pending')); - } - claimsToConfirm.push(claim); - if (onConfirmed) { - onConfirmed(claim); - } - } - }); - if (claimsToConfirm.length) { - dispatch({ - type: UPDATE_CONFIRMED_CLAIMS, - data: { - claims: claimsToConfirm + if (pendingTxos.length) { + lbryProxy.txo_list({ txid: pendingTxos }).then(result => { + const txos = result.items; + const idsToConfirm = []; + txos.forEach(txo => { + if (txo.claim_id && txo.confirmations > 0) { + idsToConfirm.push(txo.claim_id); + delete pendingById[txo.claim_id]; } }); - } - return pendingIdSet.size; - }).then(len => { - if (!len) { - clearInterval(claimCheckInterval); - } - }); + return { idsToConfirm, pendingById }; + }).then(results => { + const { idsToConfirm, pendingById } = results; + if (idsToConfirm.length) { + return lbryProxy.claim_list({ claim_id: idsToConfirm, resolve: true }).then(results => { + const claims = results.items; + const collectionIds = claims.filter(c => c.value_type === 'collection').map(c => c.claim_id); + dispatch({ + type: UPDATE_CONFIRMED_CLAIMS, + data: { + claims: claims, + pending: pendingById + } + }); + if (collectionIds.length) { + dispatch(doFetchItemsInCollections({ + collectionIds + })); + } + const channelClaims = claims.filter(claim => claim.value_type === 'channel'); + if (channelClaims.length && onChannelConfirmCallback) { + channelClaims.forEach(claim => onChannelConfirmCallback(claim)); + } + if (Object.keys(pendingById).length === 0) { + clearInterval(checkPendingInterval); + } + }); + } + }); + } else { + clearInterval(checkPendingInterval); + } }; - - claimCheckInterval = setInterval(() => { - checkClaimList(); + // do something with onConfirmed (typically get blocklist for channel) + checkPendingInterval = setInterval(() => { + checkTxoList(); }, 30000); }; @@ -6001,7 +5993,7 @@ const defaultState = { fetchingMyChannels: false, fetchingMyCollections: false, abandoningById: {}, - pendingIds: [], + pendingById: {}, reflectingById: {}, claimSearchError: false, claimSearchByQuery: {}, @@ -6035,7 +6027,7 @@ function handleClaimAction(state, action) { const byUri = Object.assign({}, state.claimsByUri); const byId = Object.assign({}, state.byId); const channelClaimCounts = Object.assign({}, state.channelClaimCounts); - const pendingIds = state.pendingIds; + const pendingById = state.pendingById; let newResolvingUrls = new Set(state.resolvingUris); let myClaimIds = new Set(state.myClaims); @@ -6045,7 +6037,7 @@ function handleClaimAction(state, action) { const channel = channelFromResolve || stream && stream.signing_channel; if (stream) { - if (pendingIds.includes(stream.claim_id)) { + if (pendingById[stream.claim_id]) { byId[stream.claim_id] = mergeClaims(stream, byId[stream.claim_id]); } else { byId[stream.claim_id] = stream; @@ -6075,7 +6067,7 @@ function handleClaimAction(state, action) { channelClaimCounts[channel.canonical_url] = claimsInChannel; } - if (pendingIds.includes(channel.claim_id)) { + if (pendingById[channel.claim_id]) { byId[channel.claim_id] = mergeClaims(channel, byId[channel.claim_id]); } else { byId[channel.claim_id] = channel; @@ -6088,7 +6080,7 @@ function handleClaimAction(state, action) { } if (collection) { - if (pendingIds.includes(collection.claim_id)) { + if (pendingById[collection.claim_id]) { byId[collection.claim_id] = mergeClaims(collection, byId[collection.claim_id]); } else { byId[collection.claim_id] = collection; @@ -6105,7 +6097,7 @@ function handleClaimAction(state, action) { } newResolvingUrls.delete(url); - if (!stream && !channel && !collection && !pendingIds.includes(byUri[url])) { + if (!stream && !channel && !collection && !pendingById[byUri[url]]) { byUri[url] = null; } }); @@ -6145,34 +6137,33 @@ reducers[FETCH_CLAIM_LIST_MINE_STARTED] = state => Object.assign({}, state, { }); reducers[FETCH_CLAIM_LIST_MINE_COMPLETED] = (state, action) => { - const { result, resolve } = action.data; + const { result } = action.data; const claims = result.items; const page = result.page; const totalItems = result.total_items; const byId = Object.assign({}, state.byId); const byUri = Object.assign({}, state.claimsByUri); - const pendingIds = state.pendingIds || []; + const pendingById = Object.assign({}, state.pendingById); let myClaimIds = new Set(state.myClaims); let urlsForCurrentPage = []; - const pendingIdSet = new Set(pendingIds); - claims.forEach(claim => { - const { permanent_url: permanentUri, claim_id: claimId } = claim; + const { permanent_url: permanentUri, claim_id: claimId, canonical_url: canonicalUri } = claim; if (claim.type && claim.type.match(/claim|update/)) { urlsForCurrentPage.push(permanentUri); if (claim.confirmations < 1) { - pendingIdSet.add(claimId); - } else if (!resolve && pendingIdSet.has(claimId) && claim.confirmations > 0) { - pendingIdSet.delete(claimId); - } - if (pendingIds.includes(claimId)) { - byId[claimId] = mergeClaims(claim, byId[claimId]); + pendingById[claimId] = claim; + if (byId[claimId]) { + byId[claimId] = mergeClaims(claim, byId[claimId]); + } else { + byId[claimId] = claim; + } } else { byId[claimId] = claim; } byUri[permanentUri] = claimId; + byUri[canonicalUri] = claimId; myClaimIds.add(claimId); } }); @@ -6181,7 +6172,7 @@ reducers[FETCH_CLAIM_LIST_MINE_COMPLETED] = (state, action) => { isFetchingClaimListMine: false, myClaims: Array.from(myClaimIds), byId, - pendingIds: Array.from(pendingIdSet), + pendingById, claimsByUri: byUri, myClaimsPageResults: urlsForCurrentPage, myClaimsPageNumber: page, @@ -6193,9 +6184,8 @@ reducers[FETCH_CHANNEL_LIST_STARTED] = state => Object.assign({}, state, { fetch reducers[FETCH_CHANNEL_LIST_COMPLETED] = (state, action) => { const { claims } = action.data; - const myClaims = state.myClaims || []; let myClaimIds = new Set(state.myClaims); - const pendingIds = state.pendingIds || []; + const pendingById = Object.assign({}, state.pendingById); let myChannelClaims; const byId = Object.assign({}, state.byId); const byUri = Object.assign({}, state.claimsByUri); @@ -6208,7 +6198,12 @@ reducers[FETCH_CHANNEL_LIST_COMPLETED] = (state, action) => { myChannelClaims = new Set(state.myChannelClaims); claims.forEach(claim => { const { claims_in_channel: claimsInChannel } = claim.meta; - const { canonical_url: canonicalUrl, permanent_url: permanentUrl, claim_id: claimId } = claim; + const { + canonical_url: canonicalUrl, + permanent_url: permanentUrl, + claim_id: claimId, + confirmations + } = claim; byUri[canonicalUrl] = claimId; byUri[permanentUrl] = claimId; @@ -6217,7 +6212,14 @@ reducers[FETCH_CHANNEL_LIST_COMPLETED] = (state, action) => { // $FlowFixMe myChannelClaims.add(claimId); - if (!pendingIds.some(c => c === claimId)) { + if (confirmations < 1) { + pendingById[claimId] = claim; + if (byId[claimId]) { + byId[claimId] = mergeClaims(claim, byId[claimId]); + } else { + byId[claimId] = claim; + } + } else { byId[claimId] = claim; } myClaimIds.add(claimId); @@ -6226,6 +6228,7 @@ reducers[FETCH_CHANNEL_LIST_COMPLETED] = (state, action) => { return Object.assign({}, state, { byId, + pendingById, claimsByUri: byUri, channelClaimCounts, fetchingMyChannels: false, @@ -6248,7 +6251,7 @@ reducers[FETCH_COLLECTION_LIST_COMPLETED] = (state, action) => { const { claims } = action.data; const myClaims = state.myClaims || []; let myClaimIds = new Set(myClaims); - const pendingIds = state.pendingIds || []; + const pendingById = Object.assign({}, state.pendingById); let myCollectionClaimsSet = new Set([]); const byId = Object.assign({}, state.byId); const byUri = Object.assign({}, state.claimsByUri); @@ -6256,7 +6259,12 @@ reducers[FETCH_COLLECTION_LIST_COMPLETED] = (state, action) => { if (claims.length) { myCollectionClaimsSet = new Set(state.myCollectionClaims); claims.forEach(claim => { - const { canonical_url: canonicalUrl, permanent_url: permanentUrl, claim_id: claimId } = claim; + const { + canonical_url: canonicalUrl, + permanent_url: permanentUrl, + claim_id: claimId, + confirmations + } = claim; byUri[canonicalUrl] = claimId; byUri[permanentUrl] = claimId; @@ -6264,7 +6272,14 @@ reducers[FETCH_COLLECTION_LIST_COMPLETED] = (state, action) => { // $FlowFixMe myCollectionClaimsSet.add(claimId); // we don't want to overwrite a pending result with a resolve - if (!pendingIds.some(c => c === claimId)) { + if (confirmations < 1) { + pendingById[claimId] = claim; + if (byId[claimId]) { + byId[claimId] = mergeClaims(claim, byId[claimId]); + } else { + byId[claimId] = claim; + } + } else { byId[claimId] = claim; } myClaimIds.add(claimId); @@ -6273,6 +6288,7 @@ reducers[FETCH_COLLECTION_LIST_COMPLETED] = (state, action) => { return _extends$9({}, state, { byId, + pendingById, claimsByUri: byUri, fetchingMyCollections: false, myCollectionClaims: Array.from(myCollectionClaimsSet), @@ -6358,9 +6374,8 @@ reducers[ABANDON_CLAIM_STARTED] = (state, action) => { reducers[UPDATE_PENDING_CLAIMS] = (state, action) => { const { claims: pendingClaims } = action.data; const byId = Object.assign({}, state.byId); + const pendingById = Object.assign({}, state.pendingById); const byUri = Object.assign({}, state.claimsByUri); - const pendingIds = state.pendingIds; - const pendingIdSet = new Set(pendingIds); let myClaimIds = new Set(state.myClaims); const myChannelClaims = new Set(state.myChannelClaims); @@ -6368,7 +6383,7 @@ reducers[UPDATE_PENDING_CLAIMS] = (state, action) => { pendingClaims.forEach(claim => { let newClaim; const { permanent_url: uri, claim_id: claimId, type, value_type: valueType } = claim; - pendingIdSet.add(claimId); + pendingById[claimId] = claim; // make sure we don't need to merge? const oldClaim = byId[claimId]; if (oldClaim && oldClaim.canonical_url) { newClaim = mergeClaims(oldClaim, claim); @@ -6388,21 +6403,22 @@ reducers[UPDATE_PENDING_CLAIMS] = (state, action) => { return Object.assign({}, state, { myClaims: Array.from(myClaimIds), byId, + pendingById, myChannelClaims: Array.from(myChannelClaims), - claimsByUri: byUri, - pendingIds: Array.from(pendingIdSet) + claimsByUri: byUri }); }; reducers[UPDATE_CONFIRMED_CLAIMS] = (state, action) => { - const { claims: confirmedClaims } = action.data; + const { + claims: confirmedClaims, + pending: pendingClaims + } = action.data; const byId = Object.assign({}, state.byId); const byUri = Object.assign({}, state.claimsByUri); - const pendingIds = state.pendingIds; - const pendingIdSet = new Set(pendingIds); - + // confirmedClaims.forEach(claim => { - const { permanent_url: permanentUri, claim_id: claimId, type } = claim; + const { claim_id: claimId, type } = claim; let newClaim = claim; const oldClaim = byId[claimId]; if (oldClaim && oldClaim.canonical_url) { @@ -6410,11 +6426,10 @@ reducers[UPDATE_CONFIRMED_CLAIMS] = (state, action) => { } if (type && type.match(/claim|update|channel/)) { byId[claimId] = newClaim; - pendingIdSet.delete(claimId); } }); return Object.assign({}, state, { - pendingIds: Array.from(pendingIdSet), + pendingById: pendingClaims, byId, claimsByUri: byUri }); @@ -7938,7 +7953,6 @@ exports.makeSelectClaimIsNsfw = makeSelectClaimIsNsfw; exports.makeSelectClaimIsPending = makeSelectClaimIsPending; exports.makeSelectClaimIsStreamPlaceholder = makeSelectClaimIsStreamPlaceholder; exports.makeSelectClaimWasPurchased = makeSelectClaimWasPurchased; -exports.makeSelectClaimsInChannelForCurrentPageState = makeSelectClaimsInChannelForCurrentPageState; exports.makeSelectClaimsInChannelForPage = makeSelectClaimsInChannelForPage; exports.makeSelectCollectionForId = makeSelectCollectionForId; exports.makeSelectCollectionForIdHasClaimUrl = makeSelectCollectionForIdHasClaimUrl; @@ -7972,7 +7986,6 @@ exports.makeSelectMyPurchasesForPage = makeSelectMyPurchasesForPage; exports.makeSelectMyStreamUrlsForPage = makeSelectMyStreamUrlsForPage; exports.makeSelectNameForCollectionId = makeSelectNameForCollectionId; exports.makeSelectNextUrlForCollectionAndUrl = makeSelectNextUrlForCollectionAndUrl; -exports.makeSelectNsfwCountForChannel = makeSelectNsfwCountForChannel; exports.makeSelectNsfwCountFromUris = makeSelectNsfwCountFromUris; exports.makeSelectOmittedCountForChannel = makeSelectOmittedCountForChannel; exports.makeSelectPendingAmountByUri = makeSelectPendingAmountByUri; diff --git a/dist/flow-typed/Lbry.js b/dist/flow-typed/Lbry.js index 7284455..2fd2ac6 100644 --- a/dist/flow-typed/Lbry.js +++ b/dist/flow-typed/Lbry.js @@ -75,7 +75,7 @@ declare type BalanceResponse = { declare type ResolveResponse = { // Keys are the url(s) passed to resolve - [string]: { error?: {}, stream?: StreamClaim, channel?: ChannelClaim, claimsInChannel?: number }, + [string]: { error?: {}, stream?: StreamClaim, channel?: ChannelClaim, collection?: CollectionClaim, claimsInChannel?: number }, }; declare type GetResponse = FileListItem & { error?: string }; @@ -351,6 +351,7 @@ declare type LbryTypes = { address_unused: (params: {}) => Promise, // New address address_list: (params: {}) => Promise, transaction_list: (params: {}) => Promise, + txo_list: (params: {}) => Promise, // Sync sync_hash: (params: {}) => Promise, diff --git a/flow-typed/Lbry.js b/flow-typed/Lbry.js index 7284455..2fd2ac6 100644 --- a/flow-typed/Lbry.js +++ b/flow-typed/Lbry.js @@ -75,7 +75,7 @@ declare type BalanceResponse = { declare type ResolveResponse = { // Keys are the url(s) passed to resolve - [string]: { error?: {}, stream?: StreamClaim, channel?: ChannelClaim, claimsInChannel?: number }, + [string]: { error?: {}, stream?: StreamClaim, channel?: ChannelClaim, collection?: CollectionClaim, claimsInChannel?: number }, }; declare type GetResponse = FileListItem & { error?: string }; @@ -351,6 +351,7 @@ declare type LbryTypes = { address_unused: (params: {}) => Promise, // New address address_list: (params: {}) => Promise, transaction_list: (params: {}) => Promise, + txo_list: (params: {}) => Promise, // Sync sync_hash: (params: {}) => Promise, diff --git a/src/index.js b/src/index.js index aba6c58..5d04fc4 100644 --- a/src/index.js +++ b/src/index.js @@ -209,7 +209,6 @@ export { makeSelectTotalItemsForChannel, makeSelectTotalPagesForChannel, makeSelectNsfwCountFromUris, - makeSelectNsfwCountForChannel, makeSelectOmittedCountForChannel, makeSelectClaimIsNsfw, makeSelectChannelForClaimUri, @@ -217,7 +216,6 @@ export { makeSelectMyChannelPermUrlForName, makeSelectClaimIsPending, makeSelectReflectingClaimForUri, - makeSelectClaimsInChannelForCurrentPageState, makeSelectShortUrlForUri, makeSelectCanonicalUrlForUri, makeSelectPermanentUrlForUri, diff --git a/src/lbry.js b/src/lbry.js index 9a73384..a7828d9 100644 --- a/src/lbry.js +++ b/src/lbry.js @@ -117,6 +117,7 @@ const Lbry: LbryTypes = { utxo_release: (params = {}) => daemonCallWithResult('utxo_release', params), support_abandon: (params = {}) => daemonCallWithResult('support_abandon', params), purchase_list: (params = {}) => daemonCallWithResult('purchase_list', params), + txo_list: (params = {}) => daemonCallWithResult('txo_list', params), sync_hash: (params = {}) => daemonCallWithResult('sync_hash', params), sync_apply: (params = {}) => daemonCallWithResult('sync_apply', params), diff --git a/src/redux/actions/claims.js b/src/redux/actions/claims.js index cee7c13..37212a1 100644 --- a/src/redux/actions/claims.js +++ b/src/redux/actions/claims.js @@ -10,6 +10,7 @@ import { selectClaimsByUri, selectMyChannelClaims, selectPendingIds, + selectPendingClaimsById, } from 'redux/selectors/claims'; import { doFetchTxoPage } from 'redux/actions/wallet'; @@ -18,15 +19,16 @@ import { creditsToString } from 'util/format-credits'; import { batchActions } from 'util/batch-actions'; import { createNormalizedClaimSearchKey } from 'util/claim'; import { PAGE_SIZE } from 'constants/claim'; -import { - selectPendingCollections, -} from 'redux/selectors/collections'; +import { selectPendingCollections } from 'redux/selectors/collections'; import { doFetchItemsInCollection, doFetchItemsInCollections, doCollectionDelete, } from 'redux/actions/collections'; +let onChannelConfirmCallback; +let checkPendingInterval; + export function doResolveUris( uris: Array, returnCachedClaims: boolean = false, @@ -402,7 +404,7 @@ export function doClearChannelErrors() { }; } -export function doCreateChannel(name: string, amount: number, optionalParams: any, cb: any) { +export function doCreateChannel(name: string, amount: number, optionalParams: any, onConfirm: any) { return (dispatch: Dispatch) => { dispatch({ type: ACTIONS.CREATE_CHANNEL_STARTED, @@ -469,7 +471,7 @@ export function doCreateChannel(name: string, amount: number, optionalParams: an claims: [channelClaim], }, }); - dispatch(doCheckPendingClaims(cb)); + dispatch(doCheckPendingClaims(onConfirm)); return channelClaim; }) .catch(error => { @@ -895,7 +897,6 @@ export function doCollectionPublishUpdate(options: { }, }); dispatch(doCheckPendingClaims()); - dispatch(doFetchCollectionListMine(1, 10)); return resolve(collectionClaim); } @@ -975,52 +976,71 @@ export function doPurchaseList(page: number = 1, pageSize: number = PAGE_SIZE) { }; } -export const doCheckPendingClaims = (onConfirmed: Function) => ( +export const doCheckPendingClaims = (onChannelConfirmed: Function) => ( dispatch: Dispatch, getState: GetState ) => { - let claimCheckInterval; - - const checkClaimList = () => { + if (onChannelConfirmed) { + onChannelConfirmCallback = onChannelConfirmed; + } + clearInterval(checkPendingInterval); + const checkTxoList = () => { const state = getState(); - const pendingIdSet = new Set(selectPendingIds(state)); + const pendingById = Object.assign({}, selectPendingClaimsById(state)); + const pendingTxos = (Object.values(pendingById): any).map(p => p.txid); + // use collections const pendingCollections = selectPendingCollections(state); - Lbry.claim_list({ page: 1, page_size: 10 }) - .then(result => { - const claims = result.items; - const claimsToConfirm = []; - claims.forEach(claim => { - const { claim_id: claimId } = claim; - if (claim.confirmations > 0 && pendingIdSet.has(claimId)) { - pendingIdSet.delete(claimId); - if (Object.keys(pendingCollections).includes(claim.claim_id)) { - dispatch(doFetchItemsInCollection({ collectionId: claim.claim_id })); - dispatch(doCollectionDelete(claim.claim_id, 'pending')); - } - claimsToConfirm.push(claim); - if (onConfirmed) { - onConfirmed(claim); + if (pendingTxos.length) { + Lbry.txo_list({ txid: pendingTxos }) + .then(result => { + const txos = result.items; + const idsToConfirm = []; + txos.forEach(txo => { + if (txo.claim_id && txo.confirmations > 0) { + idsToConfirm.push(txo.claim_id); + delete pendingById[txo.claim_id]; } + }); + return { idsToConfirm, pendingById }; + }) + .then(results => { + const { idsToConfirm, pendingById } = results; + if (idsToConfirm.length) { + return Lbry.claim_list({ claim_id: idsToConfirm, resolve: true }).then(results => { + const claims = results.items; + const collectionIds = claims + .filter(c => c.value_type === 'collection') + .map(c => c.claim_id); + dispatch({ + type: ACTIONS.UPDATE_CONFIRMED_CLAIMS, + data: { + claims: claims, + pending: pendingById, + }, + }); + if (collectionIds.length) { + dispatch( + doFetchItemsInCollections({ + collectionIds, + }) + ); + } + const channelClaims = claims.filter(claim => claim.value_type === 'channel'); + if (channelClaims.length && onChannelConfirmCallback) { + channelClaims.forEach(claim => onChannelConfirmCallback(claim)); + } + if (Object.keys(pendingById).length === 0) { + clearInterval(checkPendingInterval); + } + }); } }); - if (claimsToConfirm.length) { - dispatch({ - type: ACTIONS.UPDATE_CONFIRMED_CLAIMS, - data: { - claims: claimsToConfirm, - }, - }); - } - return pendingIdSet.size; - }) - .then(len => { - if (!len) { - clearInterval(claimCheckInterval); - } - }); + } else { + clearInterval(checkPendingInterval); + } }; - - claimCheckInterval = setInterval(() => { - checkClaimList(); + // do something with onConfirmed (typically get blocklist for channel) + checkPendingInterval = setInterval(() => { + checkTxoList(); }, 30000); }; diff --git a/src/redux/reducers/claims.js b/src/redux/reducers/claims.js index e167aac..410e032 100644 --- a/src/redux/reducers/claims.js +++ b/src/redux/reducers/claims.js @@ -17,8 +17,8 @@ type State = { channelClaimCounts: { [string]: number }, claimsByUri: { [string]: string }, byId: { [string]: Claim }, + pendingById: { [string]: Claim }, // keep pending claims resolvingUris: Array, - pendingIds: Array, reflectingById: { [string]: ReflectingUpdate }, myClaims: ?Array, myChannelClaims: ?Array, @@ -83,7 +83,7 @@ const defaultState = { fetchingMyChannels: false, fetchingMyCollections: false, abandoningById: {}, - pendingIds: [], + pendingById: {}, reflectingById: {}, claimSearchError: false, claimSearchByQuery: {}, @@ -117,7 +117,7 @@ function handleClaimAction(state: State, action: any): State { const byUri = Object.assign({}, state.claimsByUri); const byId = Object.assign({}, state.byId); const channelClaimCounts = Object.assign({}, state.channelClaimCounts); - const pendingIds = state.pendingIds; + const pendingById = state.pendingById; let newResolvingUrls = new Set(state.resolvingUris); let myClaimIds = new Set(state.myClaims); @@ -127,7 +127,7 @@ function handleClaimAction(state: State, action: any): State { const channel = channelFromResolve || (stream && stream.signing_channel); if (stream) { - if (pendingIds.includes(stream.claim_id)) { + if (pendingById[stream.claim_id]) { byId[stream.claim_id] = mergeClaim(stream, byId[stream.claim_id]); } else { byId[stream.claim_id] = stream; @@ -157,7 +157,7 @@ function handleClaimAction(state: State, action: any): State { channelClaimCounts[channel.canonical_url] = claimsInChannel; } - if (pendingIds.includes(channel.claim_id)) { + if (pendingById[channel.claim_id]) { byId[channel.claim_id] = mergeClaim(channel, byId[channel.claim_id]); } else { byId[channel.claim_id] = channel; @@ -170,7 +170,7 @@ function handleClaimAction(state: State, action: any): State { } if (collection) { - if (pendingIds.includes(collection.claim_id)) { + if (pendingById[collection.claim_id]) { byId[collection.claim_id] = mergeClaim(collection, byId[collection.claim_id]); } else { byId[collection.claim_id] = collection; @@ -187,7 +187,7 @@ function handleClaimAction(state: State, action: any): State { } newResolvingUrls.delete(url); - if (!stream && !channel && !collection && !pendingIds.includes(byUri[url])) { + if (!stream && !channel && !collection && !pendingById[byUri[url]]) { byUri[url] = null; } }); @@ -230,34 +230,33 @@ reducers[ACTIONS.FETCH_CLAIM_LIST_MINE_STARTED] = (state: State): State => }); reducers[ACTIONS.FETCH_CLAIM_LIST_MINE_COMPLETED] = (state: State, action: any): State => { - const { result, resolve }: { result: ClaimListResponse, resolve: boolean } = action.data; + const { result }: { result: ClaimListResponse } = action.data; const claims = result.items; const page = result.page; const totalItems = result.total_items; const byId = Object.assign({}, state.byId); const byUri = Object.assign({}, state.claimsByUri); - const pendingIds = state.pendingIds || []; + const pendingById = Object.assign({}, state.pendingById); let myClaimIds = new Set(state.myClaims); let urlsForCurrentPage = []; - const pendingIdSet = new Set(pendingIds); - claims.forEach((claim: Claim) => { - const { permanent_url: permanentUri, claim_id: claimId } = claim; + const { permanent_url: permanentUri, claim_id: claimId, canonical_url: canonicalUri } = claim; if (claim.type && claim.type.match(/claim|update/)) { urlsForCurrentPage.push(permanentUri); if (claim.confirmations < 1) { - pendingIdSet.add(claimId); - } else if (!resolve && pendingIdSet.has(claimId) && claim.confirmations > 0) { - pendingIdSet.delete(claimId); - } - if (pendingIds.includes(claimId)) { - byId[claimId] = mergeClaim(claim, byId[claimId]); + pendingById[claimId] = claim; + if (byId[claimId]) { + byId[claimId] = mergeClaim(claim, byId[claimId]); + } else { + byId[claimId] = claim; + } } else { byId[claimId] = claim; } byUri[permanentUri] = claimId; + byUri[canonicalUri] = claimId; myClaimIds.add(claimId); } }); @@ -266,7 +265,7 @@ reducers[ACTIONS.FETCH_CLAIM_LIST_MINE_COMPLETED] = (state: State, action: any): isFetchingClaimListMine: false, myClaims: Array.from(myClaimIds), byId, - pendingIds: Array.from(pendingIdSet), + pendingById, claimsByUri: byUri, myClaimsPageResults: urlsForCurrentPage, myClaimsPageNumber: page, @@ -279,9 +278,8 @@ reducers[ACTIONS.FETCH_CHANNEL_LIST_STARTED] = (state: State): State => reducers[ACTIONS.FETCH_CHANNEL_LIST_COMPLETED] = (state: State, action: any): State => { const { claims }: { claims: Array } = action.data; - const myClaims = state.myClaims || []; let myClaimIds = new Set(state.myClaims); - const pendingIds = state.pendingIds || []; + const pendingById = Object.assign({}, state.pendingById); let myChannelClaims; const byId = Object.assign({}, state.byId); const byUri = Object.assign({}, state.claimsByUri); @@ -295,7 +293,12 @@ reducers[ACTIONS.FETCH_CHANNEL_LIST_COMPLETED] = (state: State, action: any): St claims.forEach(claim => { const { meta } = claim; const { claims_in_channel: claimsInChannel } = claim.meta; - const { canonical_url: canonicalUrl, permanent_url: permanentUrl, claim_id: claimId } = claim; + const { + canonical_url: canonicalUrl, + permanent_url: permanentUrl, + claim_id: claimId, + confirmations, + } = claim; byUri[canonicalUrl] = claimId; byUri[permanentUrl] = claimId; @@ -304,7 +307,14 @@ reducers[ACTIONS.FETCH_CHANNEL_LIST_COMPLETED] = (state: State, action: any): St // $FlowFixMe myChannelClaims.add(claimId); - if (!pendingIds.some(c => c === claimId)) { + if (confirmations < 1) { + pendingById[claimId] = claim; + if (byId[claimId]) { + byId[claimId] = mergeClaim(claim, byId[claimId]); + } else { + byId[claimId] = claim; + } + } else { byId[claimId] = claim; } myClaimIds.add(claimId); @@ -313,6 +323,7 @@ reducers[ACTIONS.FETCH_CHANNEL_LIST_COMPLETED] = (state: State, action: any): St return Object.assign({}, state, { byId, + pendingById, claimsByUri: byUri, channelClaimCounts, fetchingMyChannels: false, @@ -336,7 +347,7 @@ reducers[ACTIONS.FETCH_COLLECTION_LIST_COMPLETED] = (state: State, action: any): const { claims }: { claims: Array } = action.data; const myClaims = state.myClaims || []; let myClaimIds = new Set(myClaims); - const pendingIds = state.pendingIds || []; + const pendingById = Object.assign({}, state.pendingById); let myCollectionClaimsSet = new Set([]); const byId = Object.assign({}, state.byId); const byUri = Object.assign({}, state.claimsByUri); @@ -345,7 +356,12 @@ reducers[ACTIONS.FETCH_COLLECTION_LIST_COMPLETED] = (state: State, action: any): myCollectionClaimsSet = new Set(state.myCollectionClaims); claims.forEach(claim => { const { meta } = claim; - const { canonical_url: canonicalUrl, permanent_url: permanentUrl, claim_id: claimId } = claim; + const { + canonical_url: canonicalUrl, + permanent_url: permanentUrl, + claim_id: claimId, + confirmations, + } = claim; byUri[canonicalUrl] = claimId; byUri[permanentUrl] = claimId; @@ -353,7 +369,14 @@ reducers[ACTIONS.FETCH_COLLECTION_LIST_COMPLETED] = (state: State, action: any): // $FlowFixMe myCollectionClaimsSet.add(claimId); // we don't want to overwrite a pending result with a resolve - if (!pendingIds.some(c => c === claimId)) { + if (confirmations < 1) { + pendingById[claimId] = claim; + if (byId[claimId]) { + byId[claimId] = mergeClaim(claim, byId[claimId]); + } else { + byId[claimId] = claim; + } + } else { byId[claimId] = claim; } myClaimIds.add(claimId); @@ -363,6 +386,7 @@ reducers[ACTIONS.FETCH_COLLECTION_LIST_COMPLETED] = (state: State, action: any): return { ...state, byId, + pendingById, claimsByUri: byUri, fetchingMyCollections: false, myCollectionClaims: Array.from(myCollectionClaimsSet), @@ -455,9 +479,8 @@ reducers[ACTIONS.ABANDON_CLAIM_STARTED] = (state: State, action: any): State => reducers[ACTIONS.UPDATE_PENDING_CLAIMS] = (state: State, action: any): State => { const { claims: pendingClaims }: { claims: Array } = action.data; const byId = Object.assign({}, state.byId); + const pendingById = Object.assign({}, state.pendingById); const byUri = Object.assign({}, state.claimsByUri); - const pendingIds = state.pendingIds; - const pendingIdSet = new Set(pendingIds); let myClaimIds = new Set(state.myClaims); const myChannelClaims = new Set(state.myChannelClaims); @@ -465,7 +488,7 @@ reducers[ACTIONS.UPDATE_PENDING_CLAIMS] = (state: State, action: any): State => pendingClaims.forEach((claim: Claim) => { let newClaim; const { permanent_url: uri, claim_id: claimId, type, value_type: valueType } = claim; - pendingIdSet.add(claimId); + pendingById[claimId] = claim; // make sure we don't need to merge? const oldClaim = byId[claimId]; if (oldClaim && oldClaim.canonical_url) { newClaim = mergeClaim(oldClaim, claim); @@ -485,21 +508,22 @@ reducers[ACTIONS.UPDATE_PENDING_CLAIMS] = (state: State, action: any): State => return Object.assign({}, state, { myClaims: Array.from(myClaimIds), byId, + pendingById, myChannelClaims: Array.from(myChannelClaims), claimsByUri: byUri, - pendingIds: Array.from(pendingIdSet), }); }; reducers[ACTIONS.UPDATE_CONFIRMED_CLAIMS] = (state: State, action: any): State => { - const { claims: confirmedClaims }: { claims: Array } = action.data; + const { + claims: confirmedClaims, + pending: pendingClaims, + }: { claims: Array, pending: { [string]: Claim } } = action.data; const byId = Object.assign({}, state.byId); const byUri = Object.assign({}, state.claimsByUri); - const pendingIds = state.pendingIds; - const pendingIdSet = new Set(pendingIds); - + // confirmedClaims.forEach((claim: GenericClaim) => { - const { permanent_url: permanentUri, claim_id: claimId, type } = claim; + const { claim_id: claimId, type } = claim; let newClaim = claim; const oldClaim = byId[claimId]; if (oldClaim && oldClaim.canonical_url) { @@ -507,11 +531,10 @@ reducers[ACTIONS.UPDATE_CONFIRMED_CLAIMS] = (state: State, action: any): State = } if (type && type.match(/claim|update|channel/)) { byId[claimId] = newClaim; - pendingIdSet.delete(claimId); } }); return Object.assign({}, state, { - pendingIds: Array.from(pendingIdSet), + pendingById: pendingClaims, byId, claimsByUri: byUri, }); diff --git a/src/redux/selectors/claims.js b/src/redux/selectors/claims.js index 683077d..0fab1c1 100644 --- a/src/redux/selectors/claims.js +++ b/src/redux/selectors/claims.js @@ -1,5 +1,5 @@ // @flow -import { normalizeURI, buildURI, parseURI } from 'lbryURI'; +import { normalizeURI, parseURI } from 'lbryURI'; import { selectSupportsByOutpoint } from 'redux/selectors/wallet'; import { createSelector } from 'reselect'; import { isClaimNsfw, filterClaims } from 'util/claim'; @@ -7,11 +7,24 @@ import * as CLAIM from 'constants/claim'; const selectState = state => state.claims || {}; -export const selectClaimsById = createSelector( +export const selectById = createSelector( selectState, state => state.byId || {} ); +export const selectPendingClaimsById = createSelector( + selectState, + state => state.pendingById || {} +); + +export const selectClaimsById = createSelector( + selectById, + selectPendingClaimsById, + (byId, pendingById) => { + return Object.assign(byId, pendingById); // do I need merged to keep metadata? + } +); + export const selectClaimIdsByUri = createSelector( selectState, state => state.claimsByUri || {} @@ -72,35 +85,35 @@ export const selectAllClaimsByChannel = createSelector( export const selectPendingIds = createSelector( selectState, - state => state.pendingIds || [] + state => Object.keys(state.pendingIds) || [] ); export const selectPendingClaims = createSelector( - selectPendingIds, - selectClaimsById, - (pendingIds, byId) => pendingIds.map(id => byId[id]) + selectPendingClaimsById, + pendingById => Object.values(pendingById) ); export const makeSelectClaimIsPending = (uri: string) => createSelector( selectClaimIdsByUri, - selectPendingIds, - (idsByUri, pendingIds) => { + selectPendingClaimsById, + (idsByUri, pendingById) => { const claimId = idsByUri[normalizeURI(uri)]; if (claimId) { - return pendingIds.some(i => i === claimId); + return Boolean(pendingById[claimId]); } return false; } ); -export const makeSelectClaimIdIsPending = (claimId: string) => createSelector( - selectPendingIds, - (pendingIds) => { - return pendingIds.some(i => i === claimId); - } -); +export const makeSelectClaimIdIsPending = (claimId: string) => + createSelector( + selectPendingClaimsById, + pendingById => { + return Boolean(pendingById[claimId]); + } + ); export const makeSelectClaimIdForUri = (uri: string) => createSelector( @@ -325,6 +338,7 @@ export const makeSelectClaimsInChannelForPage = (uri: string, page?: number) => } ); +// THIS IS LEFT OVER FROM ONE TAB CHANNEL_CONTENT export const makeSelectTotalClaimsInChannelSearch = (uri: string) => createSelector( selectClaimsById, @@ -335,6 +349,7 @@ export const makeSelectTotalClaimsInChannelSearch = (uri: string) => } ); +// THIS IS LEFT OVER FROM ONE_TAB CHANNEL CONTENT export const makeSelectTotalPagesInChannelSearch = (uri: string) => createSelector( selectClaimsById, @@ -345,21 +360,6 @@ export const makeSelectTotalPagesInChannelSearch = (uri: string) => } ); -export const makeSelectClaimsInChannelForCurrentPageState = (uri: string) => - createSelector( - selectClaimsById, - selectAllClaimsByChannel, - selectCurrentChannelPage, - (byId, allClaims, page) => { - const byChannel = allClaims[uri] || {}; - const claimIds = byChannel[page || 1]; - - if (!claimIds) return claimIds; - - return claimIds.map(claimId => byId[claimId]); - } - ); - export const makeSelectMetadataForUri = (uri: string) => createSelector( makeSelectClaimForUri(uri), @@ -500,7 +500,9 @@ export const selectMyClaims = createSelector( export const selectMyClaimsWithoutChannels = createSelector( selectMyClaims, myClaims => - myClaims.filter(claim => claim && !claim.name.match(/^@/)).sort((a, b) => a.timestamp - b.timestamp) + myClaims + .filter(claim => claim && !claim.name.match(/^@/)) + .sort((a, b) => a.timestamp - b.timestamp) ); export const selectMyClaimUrisWithoutChannels = createSelector( @@ -608,31 +610,18 @@ export const selectChannelClaimCounts = createSelector( export const makeSelectPendingClaimForUri = (uri: string) => createSelector( - selectPendingIds, - selectClaimsById, - (pending, claims) => { - let validUri; - let uriIsChannel; + selectPendingClaimsById, + pendingById => { let uriStreamName; let uriChannelName; try { - ({ - isChannel: uriIsChannel, - streamName: uriStreamName, - channelName: uriChannelName, - } = parseURI(uri)); - validUri = true; + ({ streamName: uriStreamName, channelName: uriChannelName } = parseURI(uri)); } catch (e) { return null; } - const pendingClaims = pending.map(id => claims[id]); - const matchingClaim = pendingClaims.find(claim => { - const { streamName, channelName, isChannel } = parseURI(claim.permanent_url); - if (isChannel) { - return channelName === uriChannelName; - } else { - return streamName === uriStreamName; - } + const pendingClaims = (Object.values(pendingById): any); + const matchingClaim = pendingClaims.find((claim: GenericClaim) => { + return claim.normalized_name === uriChannelName || claim.normalized_name === uriStreamName; }); return matchingClaim || null; } @@ -663,27 +652,6 @@ export const makeSelectNsfwCountFromUris = (uris: Array) => }, 0) ); -export const makeSelectNsfwCountForChannel = (uri: string) => - createSelector( - selectClaimsById, - selectAllClaimsByChannel, - selectCurrentChannelPage, - (byId, allClaims, page) => { - const byChannel = allClaims[uri] || {}; - const claimIds = byChannel[page || 1]; - - if (!claimIds) return 0; - - return claimIds.reduce((acc, claimId) => { - const claim = byId[claimId]; - if (isClaimNsfw(claim)) { - return acc + 1; - } - return acc; - }, 0); - } - ); - export const makeSelectOmittedCountForChannel = (uri: string) => createSelector( makeSelectTotalItemsForChannel(uri), @@ -763,14 +731,6 @@ export const makeSelectTagsForUri = (uri: string) => } ); -export const makeSelectChannelTagsForUri = (uri: string) => - createSelector( - makeSelectMetadataForUri(uri), - (metadata: ?GenericMetadata) => { - return (metadata && metadata.tags) || []; - } - ); - export const selectFetchingClaimSearchByQuery = createSelector( selectState, state => state.fetchingClaimSearchByQuery || {} diff --git a/src/redux/selectors/collections.js b/src/redux/selectors/collections.js index 3218e2f..24a8038 100644 --- a/src/redux/selectors/collections.js +++ b/src/redux/selectors/collections.js @@ -158,7 +158,7 @@ export const makeSelectCollectionForId = (id: string) => selectMyEditedCollections, selectPendingCollections, (bLists, rLists, uLists, eLists, pLists) => { - const collection = bLists[id] || uLists[id] || eLists[id] || rLists[id] || pLists[id]; + const collection = bLists[id] || uLists[id] || eLists[id] || pLists[id] || rLists[id]; return collection; } );