store pendingById #418

Merged
jessopb merged 7 commits from pending into master 2021-07-05 15:42:33 +02:00
2 changed files with 37 additions and 36 deletions
Showing only changes of commit 1948f63378 - Show all commits

57
dist/bundle.es.js vendored
View file

@ -1190,6 +1190,7 @@ const Lbry = {
utxo_release: (params = {}) => daemonCallWithResult('utxo_release', params), utxo_release: (params = {}) => daemonCallWithResult('utxo_release', params),
support_abandon: (params = {}) => daemonCallWithResult('support_abandon', params), support_abandon: (params = {}) => daemonCallWithResult('support_abandon', params),
purchase_list: (params = {}) => daemonCallWithResult('purchase_list', params), purchase_list: (params = {}) => daemonCallWithResult('purchase_list', params),
txo_list: (params = {}) => daemonCallWithResult('txo_list', params),
sync_hash: (params = {}) => daemonCallWithResult('sync_hash', params), sync_hash: (params = {}) => daemonCallWithResult('sync_hash', params),
sync_apply: (params = {}) => daemonCallWithResult('sync_apply', params), sync_apply: (params = {}) => daemonCallWithResult('sync_apply', params),
@ -2375,7 +2376,7 @@ const selectById = reselect.createSelector(selectState$1, state => state.byId ||
const selectPendingClaimsById = reselect.createSelector(selectState$1, state => state.pendingById || {}); const selectPendingClaimsById = reselect.createSelector(selectState$1, state => state.pendingById || {});
const selectClaimsById = reselect.createSelector(selectById, selectPendingClaimsById, (byId, pendingById) => { const selectClaimsById = reselect.createSelector(selectById, selectPendingClaimsById, (byId, pendingById) => {
return Object.assign(byId, pendingById); // do I need merged? return Object.assign(byId, pendingById); // do I need merged to keep metadata?
}); });
const selectClaimIdsByUri = reselect.createSelector(selectState$1, state => state.claimsByUri || {}); const selectClaimIdsByUri = reselect.createSelector(selectState$1, state => state.claimsByUri || {});
@ -2432,10 +2433,8 @@ const makeSelectClaimIdForUri = uri => reselect.createSelector(selectClaimIdsByU
const selectReflectingById = reselect.createSelector(selectState$1, state => state.reflectingById); const selectReflectingById = reselect.createSelector(selectState$1, state => state.reflectingById);
// use pendingFirst
const makeSelectClaimForClaimId = claimId => reselect.createSelector(selectClaimsById, byId => byId[claimId]); const makeSelectClaimForClaimId = claimId => reselect.createSelector(selectClaimsById, byId => byId[claimId]);
// use pendingFirst
const makeSelectClaimForUri = (uri, returnRepost = true) => reselect.createSelector(selectClaimIdsByUri, selectClaimsById, (byUri, byId) => { const makeSelectClaimForUri = (uri, returnRepost = true) => reselect.createSelector(selectClaimIdsByUri, selectClaimsById, (byUri, byId) => {
let validUri; let validUri;
let channelClaimId; let channelClaimId;
@ -2472,7 +2471,6 @@ const makeSelectClaimForUri = (uri, returnRepost = true) => reselect.createSelec
} }
}); });
// use pendingFirst
const selectMyClaimsRaw = reselect.createSelector(selectState$1, selectClaimsById, (state, byId) => { const selectMyClaimsRaw = reselect.createSelector(selectState$1, selectClaimsById, (state, byId) => {
const ids = state.myClaims; const ids = state.myClaims;
if (!ids) { if (!ids) {
@ -2552,7 +2550,6 @@ const selectAllFetchingChannelClaims = reselect.createSelector(selectState$1, st
const makeSelectFetchingChannelClaims = uri => reselect.createSelector(selectAllFetchingChannelClaims, fetching => fetching && fetching[uri]); const makeSelectFetchingChannelClaims = uri => reselect.createSelector(selectAllFetchingChannelClaims, fetching => fetching && fetching[uri]);
// use pendingFirst
const makeSelectClaimsInChannelForPage = (uri, page) => reselect.createSelector(selectClaimsById, selectAllClaimsByChannel, (byId, allClaims) => { const makeSelectClaimsInChannelForPage = (uri, page) => reselect.createSelector(selectClaimsById, selectAllClaimsByChannel, (byId, allClaims) => {
const byChannel = allClaims[uri] || {}; const byChannel = allClaims[uri] || {};
const claimIds = byChannel[page || 1]; const claimIds = byChannel[page || 1];
@ -2574,21 +2571,6 @@ const makeSelectTotalPagesInChannelSearch = uri => reselect.createSelector(selec
return byChannel['pageCount']; return byChannel['pageCount'];
}); });
// 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]);
// }
// );
const makeSelectMetadataForUri = uri => reselect.createSelector(makeSelectClaimForUri(uri), claim => { const makeSelectMetadataForUri = uri => reselect.createSelector(makeSelectClaimForUri(uri), claim => {
const metadata = claim && claim.value; const metadata = claim && claim.value;
return metadata || (claim === undefined ? undefined : null); return metadata || (claim === undefined ? undefined : null);
@ -2642,7 +2624,6 @@ const selectMyClaimsPageItemCount = reselect.createSelector(selectState$1, state
const selectFetchingMyClaimsPageError = reselect.createSelector(selectState$1, state => state.fetchingClaimListMinePageError); const selectFetchingMyClaimsPageError = reselect.createSelector(selectState$1, state => state.fetchingClaimListMinePageError);
// use pendingFirst
const selectMyClaims = reselect.createSelector(selectMyActiveClaims, selectClaimsById, selectAbandoningIds, (myClaimIds, byId, abandoningIds) => { const selectMyClaims = reselect.createSelector(selectMyActiveClaims, selectClaimsById, selectAbandoningIds, (myClaimIds, byId, abandoningIds) => {
const claims = []; const claims = [];
@ -2685,7 +2666,6 @@ const selectFetchingMyChannels = reselect.createSelector(selectState$1, state =>
const selectFetchingMyCollections = reselect.createSelector(selectState$1, state => state.fetchingMyCollections); const selectFetchingMyCollections = reselect.createSelector(selectState$1, state => state.fetchingMyCollections);
// use pendingFirst
const selectMyChannelClaims = reselect.createSelector(selectState$1, selectClaimsById, (state, byId) => { const selectMyChannelClaims = reselect.createSelector(selectState$1, selectClaimsById, (state, byId) => {
const ids = state.myChannelClaims; const ids = state.myChannelClaims;
if (!ids) { if (!ids) {
@ -2717,15 +2697,11 @@ const selectPlayingUri = reselect.createSelector(selectState$1, state => state.p
const selectChannelClaimCounts = reselect.createSelector(selectState$1, state => state.channelClaimCounts || {}); const selectChannelClaimCounts = reselect.createSelector(selectState$1, state => state.channelClaimCounts || {});
// JUST PENDING - change this
const makeSelectPendingClaimForUri = uri => reselect.createSelector(selectPendingClaimsById, pendingById => { const makeSelectPendingClaimForUri = uri => reselect.createSelector(selectPendingClaimsById, pendingById => {
let uriStreamName; let uriStreamName;
let uriChannelName; let uriChannelName;
try { try {
({ ({ streamName: uriStreamName, channelName: uriChannelName } = parseURI(uri));
streamName: uriStreamName,
channelName: uriChannelName
} = parseURI(uri));
} catch (e) { } catch (e) {
return null; return null;
} }
@ -4492,7 +4468,6 @@ function doCollectionPublishUpdate(options) {
} }
}); });
dispatch(doCheckPendingClaims()); dispatch(doCheckPendingClaims());
dispatch(doFetchCollectionListMine(1, 10));
return resolve(collectionClaim); return resolve(collectionClaim);
} }
@ -4596,7 +4571,7 @@ const doCheckPendingClaims = onConfirmed => (dispatch, getState) => {
if (idsToConfirm.length) { if (idsToConfirm.length) {
return lbryProxy.claim_list({ claim_id: idsToConfirm, resolve: true }).then(results => { return lbryProxy.claim_list({ claim_id: idsToConfirm, resolve: true }).then(results => {
const claims = results.items; const claims = results.items;
// what if results.items includes a collection? const collectionIds = claims.filter(c => c.value_type === 'collection').map(c => c.claim_id);
dispatch({ dispatch({
type: UPDATE_CONFIRMED_CLAIMS, type: UPDATE_CONFIRMED_CLAIMS,
data: { data: {
@ -4604,6 +4579,11 @@ const doCheckPendingClaims = onConfirmed => (dispatch, getState) => {
pending: pendingById pending: pendingById
} }
}); });
if (collectionIds.length) {
dispatch(doFetchItemsInCollections({
collectionIds
}));
}
checkPendingCallbacks.forEach(cb => cb()); checkPendingCallbacks.forEach(cb => cb());
clearInterval(checkPendingInterval); clearInterval(checkPendingInterval);
}); });
@ -6210,7 +6190,12 @@ reducers[FETCH_CHANNEL_LIST_COMPLETED] = (state, action) => {
myChannelClaims = new Set(state.myChannelClaims); myChannelClaims = new Set(state.myChannelClaims);
claims.forEach(claim => { claims.forEach(claim => {
const { claims_in_channel: claimsInChannel } = claim.meta; const { claims_in_channel: claimsInChannel } = claim.meta;
const { canonical_url: canonicalUrl, permanent_url: permanentUrl, claim_id: claimId, confirmations } = claim; const {
canonical_url: canonicalUrl,
permanent_url: permanentUrl,
claim_id: claimId,
confirmations
} = claim;
byUri[canonicalUrl] = claimId; byUri[canonicalUrl] = claimId;
byUri[permanentUrl] = claimId; byUri[permanentUrl] = claimId;
@ -6266,7 +6251,12 @@ reducers[FETCH_COLLECTION_LIST_COMPLETED] = (state, action) => {
if (claims.length) { if (claims.length) {
myCollectionClaimsSet = new Set(state.myCollectionClaims); myCollectionClaimsSet = new Set(state.myCollectionClaims);
claims.forEach(claim => { claims.forEach(claim => {
const { canonical_url: canonicalUrl, permanent_url: permanentUrl, claim_id: claimId, confirmations } = claim; const {
canonical_url: canonicalUrl,
permanent_url: permanentUrl,
claim_id: claimId,
confirmations
} = claim;
byUri[canonicalUrl] = claimId; byUri[canonicalUrl] = claimId;
byUri[permanentUrl] = claimId; byUri[permanentUrl] = claimId;
@ -6412,7 +6402,10 @@ reducers[UPDATE_PENDING_CLAIMS] = (state, action) => {
}; };
reducers[UPDATE_CONFIRMED_CLAIMS] = (state, action) => { reducers[UPDATE_CONFIRMED_CLAIMS] = (state, action) => {
const { claims: confirmedClaims, pending: pendingClaims } = action.data; const {
claims: confirmedClaims,
pending: pendingClaims
} = action.data;
const byId = Object.assign({}, state.byId); const byId = Object.assign({}, state.byId);
const byUri = Object.assign({}, state.claimsByUri); const byUri = Object.assign({}, state.claimsByUri);
// //

View file

@ -76,7 +76,7 @@ export function doResolveUris(
const collectionIds: Array<string> = []; const collectionIds: Array<string> = [];
return Lbry.resolve({ urls: urisToResolve, ...options }).then( return Lbry.resolve({ urls: urisToResolve, ...options }).then(
async(result: ResolveResponse) => { async (result: ResolveResponse) => {
let repostedResults = {}; let repostedResults = {};
const repostsToResolve = []; const repostsToResolve = [];
const fallbackResolveInfo = { const fallbackResolveInfo = {
@ -648,7 +648,7 @@ export function doClaimSearch(
} }
) { ) {
const query = createNormalizedClaimSearchKey(options); const query = createNormalizedClaimSearchKey(options);
return async(dispatch: Dispatch) => { return async (dispatch: Dispatch) => {
dispatch({ dispatch({
type: ACTIONS.CLAIM_SEARCH_STARTED, type: ACTIONS.CLAIM_SEARCH_STARTED,
data: { query: query }, data: { query: query },
@ -897,7 +897,6 @@ export function doCollectionPublishUpdate(options: {
}, },
}); });
dispatch(doCheckPendingClaims()); dispatch(doCheckPendingClaims());
dispatch(doFetchCollectionListMine(1, 10));
return resolve(collectionClaim); return resolve(collectionClaim);
} }
@ -1006,7 +1005,9 @@ export const doCheckPendingClaims = (onConfirmed: Function) => (
if (idsToConfirm.length) { if (idsToConfirm.length) {
return Lbry.claim_list({ claim_id: idsToConfirm, resolve: true }).then(results => { return Lbry.claim_list({ claim_id: idsToConfirm, resolve: true }).then(results => {
const claims = results.items; const claims = results.items;
// what if results.items includes a collection? const collectionIds = claims
.filter(c => c.value_type === 'collection')
.map(c => c.claim_id);
dispatch({ dispatch({
type: ACTIONS.UPDATE_CONFIRMED_CLAIMS, type: ACTIONS.UPDATE_CONFIRMED_CLAIMS,
data: { data: {
@ -1014,6 +1015,13 @@ export const doCheckPendingClaims = (onConfirmed: Function) => (
pending: pendingById, pending: pendingById,
}, },
}); });
if (collectionIds.length) {
dispatch(
doFetchItemsInCollections({
collectionIds,
})
);
}
checkPendingCallbacks.forEach(cb => cb()); checkPendingCallbacks.forEach(cb => cb());
clearInterval(checkPendingInterval); clearInterval(checkPendingInterval);
}); });