chat pic
This commit is contained in:
@@ -970,10 +970,13 @@ const getPostsWeb = async (req, res, next) => {
|
||||
lng,
|
||||
feedMode,
|
||||
seedPostId,
|
||||
sort,
|
||||
} = req.query;
|
||||
|
||||
const reelsMode = feedMode === "reels" || type === "video";
|
||||
const gridMode = feedMode === "grid";
|
||||
// فید اصلی صفحه پستها: فقط جدیدترینها (بدون شخصیسازی)
|
||||
const latestMode = sort === "latest" && !reelsMode;
|
||||
|
||||
const postFilter = { status: { $ne: null } };
|
||||
if (type === 'video' || type === 'image') {
|
||||
@@ -1090,6 +1093,24 @@ const getPostsWeb = async (req, res, next) => {
|
||||
|
||||
explorePosts = await mapPostsWithUsers(explorePosts, usersMap, decodedToken);
|
||||
|
||||
// فید اصلی: فقط جدیدترینها بر اساس تاریخ ساخت
|
||||
if (latestMode) {
|
||||
explorePosts.sort(
|
||||
(a, b) => new Date(b.createdAt) - new Date(a.createdAt)
|
||||
);
|
||||
const totalItems = explorePosts.length;
|
||||
const startIndex = (parseInt(page, 10) - 1) * parseInt(limit, 10);
|
||||
const paginatedPosts = explorePosts.slice(
|
||||
startIndex,
|
||||
startIndex + parseInt(limit, 10)
|
||||
);
|
||||
return res.status(200).json({
|
||||
posts: paginatedPosts,
|
||||
totalPages: Math.ceil(totalItems / limit) || 1,
|
||||
totalItems,
|
||||
});
|
||||
}
|
||||
|
||||
const { posts: paginatedPosts, totalItems } = await paginatePersonalizedExplore({
|
||||
posts: explorePosts,
|
||||
usersById,
|
||||
|
||||
Reference in New Issue
Block a user