Skip to content

Commit 826c534

Browse files
committed
Media filter excludes boosts
1 parent dde8af1 commit 826c534

File tree

1 file changed

+24
-23
lines changed

1 file changed

+24
-23
lines changed

src/pages/year-in-posts.jsx

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -312,35 +312,37 @@ function YearInPosts() {
312312
if (dayPosts.length > 0) {
313313
const postsWithMedia = dayPosts.filter((post) => {
314314
const actualPost = post.reblog || post;
315-
return actualPost.mediaAttachments?.some(
316-
(media) =>
317-
media.previewUrl ||
318-
media.url ||
319-
media.previewRemoteUrl ||
320-
media.remoteUrl,
315+
return (
316+
!post.reblog &&
317+
actualPost.mediaAttachments?.some(
318+
(media) =>
319+
media.previewUrl ||
320+
media.url ||
321+
media.previewRemoteUrl ||
322+
media.remoteUrl,
323+
)
321324
);
322325
});
323326

324327
if (postsWithMedia.length > 0) {
325-
bestPost = postsWithMedia.reduce((currentBest, post) => {
326-
const actualPost = post.reblog || post;
327-
const engagementScore =
328+
bestPost = postsWithMedia.reduce((topPost, post) => {
329+
const actualPost = post;
330+
const totalCount =
328331
(actualPost.favouritesCount || 0) +
329332
(actualPost.reblogsCount || 0) +
330333
(actualPost.repliesCount || 0) +
331334
(actualPost.quotesCount || 0);
332335

333-
const bestEngagementScore = currentBest
334-
? ((currentBest.reblog || currentBest).favouritesCount || 0) +
335-
((currentBest.reblog || currentBest).reblogsCount || 0) +
336-
((currentBest.reblog || currentBest).repliesCount || 0) +
337-
((currentBest.reblog || currentBest).quotesCount || 0)
336+
const topTotalCount = topPost
337+
? (topPost.favouritesCount || 0) +
338+
(topPost.reblogsCount || 0) +
339+
(topPost.repliesCount || 0) +
340+
(topPost.quotesCount || 0)
338341
: -1;
339342

340-
if (engagementScore > bestEngagementScore) return post;
341-
if (engagementScore === bestEngagementScore)
342-
return currentBest || post;
343-
return currentBest;
343+
if (totalCount > topTotalCount) return post;
344+
if (totalCount === topTotalCount) return topPost || post;
345+
return topPost;
344346
}, null);
345347
hasMedia = true;
346348
}
@@ -494,7 +496,7 @@ function YearInPosts() {
494496
}
495497

496498
const status = post.reblog || post;
497-
if (status.mediaAttachments?.length > 0) {
499+
if (!post.reblog && status.mediaAttachments?.length > 0) {
498500
counts.media++;
499501
}
500502
});
@@ -508,7 +510,7 @@ function YearInPosts() {
508510
return !!post.reblog;
509511
} else if (postType === 'media') {
510512
const status = post.reblog || post;
511-
return status.mediaAttachments?.length > 0;
513+
return !post.reblog && status.mediaAttachments?.length > 0;
512514
} else if (postType === 'quotes') {
513515
return (
514516
supportsNativeQuote() &&
@@ -1001,7 +1003,7 @@ function YearInPosts() {
10011003
<>
10021004
<ul class="timeline">
10031005
{filteredPosts.length === 0 ? (
1004-
<>{/* Nada */}</>
1006+
<p class="ui-state insignificant"></p>
10051007
) : totalPosts > 20 ? (
10061008
filteredPosts.map((post) => (
10071009
<IntersectionPostItem
@@ -1195,8 +1197,7 @@ function CalendarBar({ year, month, monthsWithPosts, postType }) {
11951197
return <span key={i} class="media-day empty" />;
11961198
if (!item.hasMedia)
11971199
return <span key={i} class="media-day no-media" />;
1198-
const post = item.post;
1199-
const status = post.reblog || post;
1200+
const status = item.post;
12001201
const media = status.mediaAttachments?.[0];
12011202
return (
12021203
<span key={i} class="media-day">

0 commit comments

Comments
 (0)