Prevent pinned posts from being grouped

This commit is contained in:
Lim Chee Aun 2023-11-13 16:57:15 +08:00
parent 3a326194ad
commit 770f4d9205

View file

@ -65,12 +65,28 @@ function Timeline({
try {
let { done, value } = await fetchItems(firstLoad);
if (Array.isArray(value)) {
// Avoid grouping for pinned posts
const [pinnedPosts, otherPosts] = value.reduce(
(acc, item) => {
if (item._pinned) {
acc[0].push(item);
} else {
acc[1].push(item);
}
return acc;
},
[[], []],
);
value = otherPosts;
if (allowGrouping) {
if (boostsCarousel) {
value = groupBoosts(value);
}
value = groupContext(value);
}
if (pinnedPosts.length) {
value = pinnedPosts.concat(value);
}
console.log(value);
if (firstLoad) {
setItems(value);