Fix batch resolve
This commit is contained in:
parent
7c3cbaca15
commit
c4a23ff856
1 changed files with 22 additions and 20 deletions
|
@ -65,7 +65,9 @@ export function doCommentList(
|
|||
const { items: comments, total_items, total_filtered_items, total_pages } = result;
|
||||
|
||||
const commentChannelUrls = comments && comments.map((comment) => comment.channel_url || '');
|
||||
const dispatchData = {
|
||||
|
||||
const returnResult = () => {
|
||||
dispatch({
|
||||
type: ACTIONS.COMMENT_LIST_COMPLETED,
|
||||
data: {
|
||||
comments,
|
||||
|
@ -77,20 +79,20 @@ export function doCommentList(
|
|||
creatorClaimId,
|
||||
uri,
|
||||
},
|
||||
});
|
||||
return result;
|
||||
};
|
||||
|
||||
// Batch resolve comment channel urls
|
||||
if (commentChannelUrls) {
|
||||
return dispatch(async () => await doResolveUris(commentChannelUrls, true)).then(() => {
|
||||
dispatch({ ...dispatchData });
|
||||
const resolve = async () => await doResolveUris(commentChannelUrls, true);
|
||||
|
||||
return result;
|
||||
});
|
||||
} else {
|
||||
dispatch({ ...dispatchData });
|
||||
|
||||
return result;
|
||||
return resolve()
|
||||
.then(() => dispatch(doResolveUris(commentChannelUrls, true)).then(() => returnResult()))
|
||||
.catch(() => returnResult());
|
||||
}
|
||||
|
||||
returnResult();
|
||||
})
|
||||
.catch((error) => {
|
||||
const { message } = error;
|
||||
|
|
Loading…
Reference in a new issue