diff --git a/src/components/timeline.jsx b/src/components/timeline.jsx index ca2b1d59..f5968a6b 100644 --- a/src/components/timeline.jsx +++ b/src/components/timeline.jsx @@ -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);