From c05023e0dd0b6b0229557d7e376d446478b08bc4 Mon Sep 17 00:00:00 2001 From: Soma Date: Sat, 13 Feb 2021 07:23:26 -0800 Subject: [PATCH 1/2] updating code for likes page bug --- src/models.js | 10 +++++++--- src/views/index.js | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/models.js b/src/models.js index 1000cdd..bf744c8 100644 --- a/src/models.js +++ b/src/models.js @@ -787,9 +787,11 @@ module.exports = ({ cooler, isPublic }) => { .filter(([, value]) => value === 1) .map(([key]) => key); - // get an array of voter names, for display on hover - const pendingVoterNames = voters.map((author) => - models.about.name(author) + // get an array of voter names, for display on hovers + const pendingVoterNames = voters.map(async (author) => ({ + name: await models.about.name(author), + key: author + }) ); const voterNames = await Promise.all(pendingVoterNames); @@ -1044,10 +1046,12 @@ module.exports = ({ cooler, isPublic }) => { ); }), pull.take(maxMessages), + pull.unique(message => message.value.content.vote.link), pullParallelMap(async (val, cb) => { const msg = await post.get(val.value.content.vote.link); cb(null, msg); }), + pull.filter((message) => message.value.meta.votes.map(voter => voter.key).includes(feed)), pull.collect((err, collectedMessages) => { if (err) { reject(err); diff --git a/src/views/index.js b/src/views/index.js index d144ad6..dcd825c 100644 --- a/src/views/index.js +++ b/src/views/index.js @@ -382,6 +382,7 @@ const post = ({ msg, aside = false }) => { const likedByNames = msg.value.meta.votes .slice(0, maxLikedNames) + .map((person) => person.name) .map((name) => name.slice(0, maxLikedNameLength)) .join(", "); From 519d0e55f0206e4fe8c8118d93044f503ed48d75 Mon Sep 17 00:00:00 2001 From: Soma Date: Sat, 13 Feb 2021 07:33:28 -0800 Subject: [PATCH 2/2] fix linting issues --- src/models.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/models.js b/src/models.js index bf744c8..8992101 100644 --- a/src/models.js +++ b/src/models.js @@ -789,10 +789,9 @@ module.exports = ({ cooler, isPublic }) => { // get an array of voter names, for display on hovers const pendingVoterNames = voters.map(async (author) => ({ - name: await models.about.name(author), - key: author - }) - ); + name: await models.about.name(author), + key: author, + })); const voterNames = await Promise.all(pendingVoterNames); const { name, avatarId, avatarUrl } = await getUserInfo( @@ -1046,12 +1045,14 @@ module.exports = ({ cooler, isPublic }) => { ); }), pull.take(maxMessages), - pull.unique(message => message.value.content.vote.link), + pull.unique((message) => message.value.content.vote.link), pullParallelMap(async (val, cb) => { const msg = await post.get(val.value.content.vote.link); cb(null, msg); }), - pull.filter((message) => message.value.meta.votes.map(voter => voter.key).includes(feed)), + pull.filter((message) => + message.value.meta.votes.map((voter) => voter.key).includes(feed) + ), pull.collect((err, collectedMessages) => { if (err) { reject(err);