mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-01-22 16:46:28 +01:00
Prevent pinned posts from being grouped
This commit is contained in:
parent
3a326194ad
commit
770f4d9205
1 changed files with 16 additions and 0 deletions
|
@ -65,12 +65,28 @@ function Timeline({
|
||||||
try {
|
try {
|
||||||
let { done, value } = await fetchItems(firstLoad);
|
let { done, value } = await fetchItems(firstLoad);
|
||||||
if (Array.isArray(value)) {
|
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 (allowGrouping) {
|
||||||
if (boostsCarousel) {
|
if (boostsCarousel) {
|
||||||
value = groupBoosts(value);
|
value = groupBoosts(value);
|
||||||
}
|
}
|
||||||
value = groupContext(value);
|
value = groupContext(value);
|
||||||
}
|
}
|
||||||
|
if (pinnedPosts.length) {
|
||||||
|
value = pinnedPosts.concat(value);
|
||||||
|
}
|
||||||
console.log(value);
|
console.log(value);
|
||||||
if (firstLoad) {
|
if (firstLoad) {
|
||||||
setItems(value);
|
setItems(value);
|
||||||
|
|
Loading…
Reference in a new issue