bugfixing
This commit is contained in:
parent
918647afb8
commit
4a8500e8ca
@ -141,7 +141,6 @@ module.exports = function (fastify, opts, done) {
|
|||||||
else {
|
else {
|
||||||
filter = `pinned=false`;
|
filter = `pinned=false`;
|
||||||
}
|
}
|
||||||
|
|
||||||
posts = await pb.collection('posts').getList(data?.startPage, 50, {
|
posts = await pb.collection('posts').getList(data?.startPage, 50, {
|
||||||
sort: sort,
|
sort: sort,
|
||||||
filter: filter,
|
filter: filter,
|
||||||
@ -151,13 +150,14 @@ module.exports = function (fastify, opts, done) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
posts = posts.items
|
posts = posts.items
|
||||||
// Add hotness property to each post
|
// Add hotness property to each post
|
||||||
posts?.forEach(post => {
|
if(data?.sortingPosts === 'hot') {
|
||||||
post.hotness = postHotness(post?.upvote, post?.created);
|
posts?.forEach(post => {
|
||||||
});
|
post.hotness = postHotness(post?.upvote, post?.created);
|
||||||
|
});
|
||||||
posts?.sort((a, b) => b?.hotness - a?.hotness);
|
|
||||||
|
|
||||||
|
posts?.sort((a, b) => b?.hotness - a?.hotness);
|
||||||
|
}
|
||||||
|
|
||||||
pinnedPost = await pb.collection('posts').getFullList({
|
pinnedPost = await pb.collection('posts').getFullList({
|
||||||
filter: `pinned=true`,
|
filter: `pinned=true`,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user