Fix batch resolve

This commit is contained in:
Rafael 2022-03-03 11:40:28 -03:00 committed by Thomas Zarebczan
parent 7c3cbaca15
commit c4a23ff856

View file

@ -65,7 +65,9 @@ export function doCommentList(
const { items: comments, total_items, total_filtered_items, total_pages } = result; const { items: comments, total_items, total_filtered_items, total_pages } = result;
const commentChannelUrls = comments && comments.map((comment) => comment.channel_url || ''); const commentChannelUrls = comments && comments.map((comment) => comment.channel_url || '');
const dispatchData = {
const returnResult = () => {
dispatch({
type: ACTIONS.COMMENT_LIST_COMPLETED, type: ACTIONS.COMMENT_LIST_COMPLETED,
data: { data: {
comments, comments,
@ -77,20 +79,20 @@ export function doCommentList(
creatorClaimId, creatorClaimId,
uri, uri,
}, },
});
return result;
}; };
// Batch resolve comment channel urls // Batch resolve comment channel urls
if (commentChannelUrls) { if (commentChannelUrls) {
return dispatch(async () => await doResolveUris(commentChannelUrls, true)).then(() => { const resolve = async () => await doResolveUris(commentChannelUrls, true);
dispatch({ ...dispatchData });
return result; return resolve()
}); .then(() => dispatch(doResolveUris(commentChannelUrls, true)).then(() => returnResult()))
} else { .catch(() => returnResult());
dispatch({ ...dispatchData });
return result;
} }
returnResult();
}) })
.catch((error) => { .catch((error) => {
const { message } = error; const { message } = error;