Skip to content
This repository has been archived by the owner on Dec 27, 2022. It is now read-only.

Commit

Permalink
Merge votes from authed user's secondary with community indexes
Browse files Browse the repository at this point in the history
  • Loading branch information
pfrazee committed Feb 10, 2021
1 parent bf9bcc8 commit 5aa1047
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions db/util.js
Expand Up @@ -71,12 +71,16 @@ export async function fetchVotes (subject, userIdxId = undefined) {
if (subject?.value?.community?.userId) {
// fetch votes in post's community index
let votesCommunityIdxEntry
let votesUserIdxEntry
if (publicUserDbs.has(subject.value.community.userId)) {
votesCommunityIdxEntry = await publicUserDbs.get(subject.value.community.userId).votesIdx.get(subject.url)
}
subjectInfo = votesCommunityIdxEntry?.value?.subject
upvoteUrls = votesCommunityIdxEntry?.value?.upvoteUrls || []
downvoteUrls = votesCommunityIdxEntry?.value?.downvoteUrls || []
if (userIdxId && privateUserDbs.has(userIdxId)) {
votesUserIdxEntry = await privateUserDbs.get(userIdxId).votesIdx.get(subject.url)
}
subjectInfo = votesCommunityIdxEntry?.value?.subject || votesUserIdxEntry?.value?.subject
upvoteUrls = concatUniq(votesCommunityIdxEntry?.value?.upvoteUrls, votesUserIdxEntry?.value?.upvoteUrls)
downvoteUrls = concatUniq(votesCommunityIdxEntry?.value?.downvoteUrls, votesUserIdxEntry?.value?.downvoteUrls)
} else {
// fetch votes in author and authed-user indexes
let votesAuthorIdxEntry
Expand Down

0 comments on commit 5aa1047

Please sign in to comment.