mirror of
https://github.com/PretendoNetwork/juxtaposition-ui.git
synced 2026-04-24 15:27:00 -05:00
fix: #96 Yeah sections on other profiles always shows the post yeahed from the user instead
Some checks failed
Build and Publish Docker Image / build-publish (push) Has been cancelled
Some checks failed
Build and Publish Docker Image / build-publish (push) Has been cancelled
This commit is contained in:
parent
2511e762e0
commit
e2c4a39b2e
|
|
@ -227,16 +227,7 @@ async function userRelations(req, res, userID) {
|
|||
let followers; let communities; let communityMap; let selection;
|
||||
|
||||
if (req.params.type === 'yeahs') {
|
||||
const posts = await POST.find({ yeahs: req.pid, removed: false }).sort({created_at: -1}).limit(config.post_limit);
|
||||
/*let posts = await POST.aggregate([
|
||||
{ $match: { id: { $in: likesArray } } },
|
||||
{$addFields: {
|
||||
"__order": { $indexOfArray: [ likesArray, "$id" ] }
|
||||
}},
|
||||
{ $sort: { "__order": 1 } },
|
||||
{ $project: { index: 0, _id: 0 } },
|
||||
{ $limit: config.post_limit }
|
||||
]);*/
|
||||
const posts = await POST.find({ yeahs: userID, removed: false }).sort({created_at: -1}).limit(config.post_limit);
|
||||
const communityMap = await util.getCommunityHash();
|
||||
const bundle = {
|
||||
posts,
|
||||
|
|
@ -371,31 +362,15 @@ async function morePosts(req, res, userID) {
|
|||
|
||||
async function moreYeahPosts(req, res, userID) {
|
||||
let offset = parseInt(req.query.offset);
|
||||
const userContent = await database.getUserContent(req.pid);
|
||||
const userContent = await database.getUserContent(userID);
|
||||
const communityMap = await util.getCommunityHash();
|
||||
if (!offset) {
|
||||
offset = 0;
|
||||
}
|
||||
let likesArray;
|
||||
try {
|
||||
likesArray = await userContent.likes.slice().reverse();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
likesArray = [];
|
||||
}
|
||||
const posts = await POST.aggregate([
|
||||
{ $match: { id: { $in: likesArray }, removed: false } },
|
||||
{$addFields: {
|
||||
'__order': { $indexOfArray: [ likesArray, '$id' ] }
|
||||
}},
|
||||
{ $sort: { '__order': 1 } },
|
||||
{ $project: { index: 0, _id: 0 } },
|
||||
{ $skip : offset },
|
||||
{ $limit: config.post_limit }
|
||||
]);
|
||||
const posts = await POST.find({ yeahs: userID, removed: false }).sort({created_at: -1}).skip(offset).limit(config.post_limit);
|
||||
|
||||
const bundle = {
|
||||
posts: posts.reverse(),
|
||||
posts: posts,
|
||||
numPosts: posts.length,
|
||||
open: true,
|
||||
communityMap,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user