Merge pull request #276 from lbryio/resolveLists

list resolve defaults to true
This commit is contained in:
Sean Yesmunt 2020-02-13 09:57:45 -05:00 committed by GitHub
commit 50c69fe1dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 49 additions and 19 deletions

35
dist/bundle.es.js vendored
View file

@ -2881,13 +2881,13 @@ function doResolveUri(uri) {
return doResolveUris([uri]); return doResolveUris([uri]);
} }
function doFetchClaimListMine(page = 1, pageSize = 99999) { function doFetchClaimListMine(page = 1, pageSize = 99999, resolve = true) {
return dispatch => { return dispatch => {
dispatch({ dispatch({
type: FETCH_CLAIM_LIST_MINE_STARTED type: FETCH_CLAIM_LIST_MINE_STARTED
}); });
lbryProxy.claim_list({ page, page_size: pageSize, claim_type: ['stream', 'repost'] }).then(result => { lbryProxy.claim_list({ page, page_size: pageSize, claim_type: ['stream', 'repost'], resolve }).then(result => {
const claims = result.items; const claims = result.items;
dispatch({ dispatch({
@ -3142,16 +3142,18 @@ function doImportChannel(certificate) {
}; };
} }
function doFetchChannelListMine(page = 1, pageSize = 99999, resolve = false) { function doFetchChannelListMine(page = 1, pageSize = 99999, resolve = true) {
return dispatch => { return dispatch => {
dispatch({ dispatch({
type: FETCH_CHANNEL_LIST_STARTED type: FETCH_CHANNEL_LIST_STARTED
}); });
const callback = response => { const callback = response => {
const { items } = response;
dispatch({ dispatch({
type: FETCH_CHANNEL_LIST_COMPLETED, type: FETCH_CHANNEL_LIST_COMPLETED,
data: { claims: response.items } data: { claims: items }
}); });
}; };
@ -4638,27 +4640,40 @@ reducers[FETCH_CHANNEL_LIST_COMPLETED] = (state, action) => {
const pendingById = Object.assign(state.pendingById); const pendingById = Object.assign(state.pendingById);
let myChannelClaims; let myChannelClaims;
let byId = Object.assign({}, state.byId); const byId = Object.assign({}, state.byId);
const byUri = Object.assign({}, state.claimsByUri);
const channelClaimCounts = Object.assign({}, state.channelClaimCounts);
if (!claims.length) { if (!claims.length) {
// $FlowFixMe // $FlowFixMe
myChannelClaims = null; myChannelClaims = null;
} else { } else {
myChannelClaims = new Set(state.myChannelClaims); myChannelClaims = new Set(state.myChannelClaims);
claims.forEach(claim => { claims.forEach(claim => {
const { claims_in_channel: claimsInChannel } = claim.meta;
const { canonical_url: canonicalUrl, permanent_url: permanentUrl, claim_id: claimId } = claim;
byUri[canonicalUrl] = claimId;
byUri[permanentUrl] = claimId;
channelClaimCounts[canonicalUrl] = claimsInChannel;
channelClaimCounts[permanentUrl] = claimsInChannel;
// $FlowFixMe // $FlowFixMe
myChannelClaims.add(claim.claim_id); myChannelClaims.add(claimId);
if (!byId[claim.claim_id]) { if (!byId[claimId]) {
byId[claim.claim_id] = claim; byId[claimId] = claim;
} }
if (pendingById[claim.claim_id] && claim.confirmations > 0) { if (pendingById[claimId] && claim.confirmations > 0) {
delete pendingById[claim.claim_id]; delete pendingById[claimId];
} }
}); });
} }
return Object.assign({}, state, { return Object.assign({}, state, {
byId, byId,
claimsByUri: byUri,
channelClaimCounts,
fetchingMyChannels: false, fetchingMyChannels: false,
myChannelClaims, myChannelClaims,
myClaims: concatClaims(myClaims, claims) myClaims: concatClaims(myClaims, claims)

View file

@ -94,13 +94,13 @@ export function doResolveUri(uri: string) {
return doResolveUris([uri]); return doResolveUris([uri]);
} }
export function doFetchClaimListMine(page: number = 1, pageSize: number = 99999) { export function doFetchClaimListMine(page: number = 1, pageSize: number = 99999, resolve: boolean = true) {
return (dispatch: Dispatch) => { return (dispatch: Dispatch) => {
dispatch({ dispatch({
type: ACTIONS.FETCH_CLAIM_LIST_MINE_STARTED, type: ACTIONS.FETCH_CLAIM_LIST_MINE_STARTED,
}); });
Lbry.claim_list({ page, page_size: pageSize, claim_type: ['stream', 'repost'] }).then( Lbry.claim_list({ page, page_size: pageSize, claim_type: ['stream', 'repost'], resolve }).then(
(result: StreamListResponse) => { (result: StreamListResponse) => {
const claims = result.items; const claims = result.items;
@ -385,13 +385,14 @@ export function doImportChannel(certificate: string) {
}; };
} }
export function doFetchChannelListMine(page: number = 1, pageSize: number = 99999, resolve: boolean = false) { export function doFetchChannelListMine(page: number = 1, pageSize: number = 99999, resolve: boolean = true) {
return (dispatch: Dispatch) => { return (dispatch: Dispatch) => {
dispatch({ dispatch({
type: ACTIONS.FETCH_CHANNEL_LIST_STARTED, type: ACTIONS.FETCH_CHANNEL_LIST_STARTED,
}); });
const callback = (response: ChannelListResponse) => { const callback = (response: ChannelListResponse) => {
dispatch({ dispatch({
type: ACTIONS.FETCH_CHANNEL_LIST_COMPLETED, type: ACTIONS.FETCH_CHANNEL_LIST_COMPLETED,
data: { claims: response.items }, data: { claims: response.items },

View file

@ -211,27 +211,41 @@ reducers[ACTIONS.FETCH_CHANNEL_LIST_COMPLETED] = (state: State, action: any): St
const pendingById = Object.assign(state.pendingById); const pendingById = Object.assign(state.pendingById);
let myChannelClaims; let myChannelClaims;
let byId = Object.assign({}, state.byId); const byId = Object.assign({}, state.byId);
const byUri = Object.assign({}, state.claimsByUri);
const channelClaimCounts = Object.assign({}, state.channelClaimCounts);
if (!claims.length) { if (!claims.length) {
// $FlowFixMe // $FlowFixMe
myChannelClaims = null; myChannelClaims = null;
} else { } else {
myChannelClaims = new Set(state.myChannelClaims); myChannelClaims = new Set(state.myChannelClaims);
claims.forEach(claim => { claims.forEach(claim => {
const { meta } = claim;
const { claims_in_channel: claimsInChannel } = claim.meta;
const { canonical_url: canonicalUrl, permanent_url: permanentUrl, claim_id: claimId } = claim;
byUri[canonicalUrl] = claimId;
byUri[permanentUrl] = claimId;
channelClaimCounts[canonicalUrl] = claimsInChannel;
channelClaimCounts[permanentUrl] = claimsInChannel;
// $FlowFixMe // $FlowFixMe
myChannelClaims.add(claim.claim_id); myChannelClaims.add(claimId);
if (!byId[claim.claim_id]) { if (!byId[claimId]) {
byId[claim.claim_id] = claim; byId[claimId] = claim;
} }
if (pendingById[claim.claim_id] && claim.confirmations > 0) { if (pendingById[claimId] && claim.confirmations > 0) {
delete pendingById[claim.claim_id]; delete pendingById[claimId];
} }
}); });
} }
return Object.assign({}, state, { return Object.assign({}, state, {
byId, byId,
claimsByUri: byUri,
channelClaimCounts,
fetchingMyChannels: false, fetchingMyChannels: false,
myChannelClaims, myChannelClaims,
myClaims: concatClaims(myClaims, claims), myClaims: concatClaims(myClaims, claims),