diff --git a/src/providers/steem/dsteem.js b/src/providers/steem/dsteem.js index c06eaf57f..21ed0fce2 100644 --- a/src/providers/steem/dsteem.js +++ b/src/providers/steem/dsteem.js @@ -321,9 +321,9 @@ export const getPostsSummary = async (by, query, currentUserName, filterNsfw) => export const getUserComments = async query => { try { - let comments = await client.database.getDiscussions('comments', query); - comments = await parseComments(comments); - return comments; + const comments = await client.database.getDiscussions('comments', query); + const groomedComments = await parseComments(comments); + return groomedComments; } catch (error) { return error; } @@ -331,13 +331,13 @@ export const getUserComments = async query => { export const getRepliesByLastUpdate = async query => { try { - let replies = await client.database.call('get_replies_by_last_update', [ + const replies = await client.database.call('get_replies_by_last_update', [ query.start_author, query.start_permlink, query.limit, ]); - replies = await parseComments(replies); - return replies; + const groomedComments = await parseComments(replies); + return groomedComments; } catch (error) { return error; } @@ -405,15 +405,11 @@ export const deleteComment = (currentAccount, pin, permlink) => { } }; -const wait = ms => new Promise(r => setTimeout(r, ms)); - export const getComments = async (author, permlink, currentUserName = null) => { try { const comments = await client.database.call('get_content_replies', [author, permlink]); const groomedComments = await parseComments(comments, currentUserName); - // WORK ARROUND - await wait(comments && comments.length * 30); return comments ? groomedComments : null; } catch (error) { diff --git a/src/utils/postParser.js b/src/utils/postParser.js index 28124cded..75518b274 100644 --- a/src/utils/postParser.js +++ b/src/utils/postParser.js @@ -102,7 +102,7 @@ const postImage = (metaData, body) => { }; export const parseComments = async (comments, currentUserName) => { - const _comments = await comments.map(async comment => { + const pArray = comments.map(async comment => { const activeVotes = await getActiveVotes(get(comment, 'author'), get(comment, 'permlink')); comment.pending_payout_value = parseFloat( @@ -120,11 +120,12 @@ export const parseComments = async (comments, currentUserName) => { } else { comment.is_voted = false; } - - return _comments; + return comment; }); - return comments; + const _comments = await Promise.all(pArray); + + return _comments; }; const isVoted = (activeVotes, currentUserName) =>