Merge dup boosts in Catch-up

This commit is contained in:
Lim Chee Aun 2024-03-10 23:24:17 +08:00
parent 0e1be5dbdc
commit f5ea96a093
2 changed files with 43 additions and 3 deletions

View file

@ -626,10 +626,24 @@
gap: 4px;
align-items: center;
flex-shrink: 0;
min-height: 24px;
.icon {
> .avatar {
outline: 1px solid var(--bg-blur-color);
}
> .avatar ~ .avatar {
margin-left: -8px;
}
> .icon {
color: var(--reblog-color);
}
> .name-text {
opacity: 0.75;
filter: grayscale(0.75);
}
}
.post-author {

View file

@ -429,9 +429,29 @@ function Catchup() {
return postFilterMatches;
});
// Deduplicate boosts
const boostedPosts = {};
filteredPosts = filteredPosts.filter((post) => {
if (post.reblog) {
if (boostedPosts[post.reblog.id]) {
if (boostedPosts[post.reblog.id].__BOOSTERS) {
boostedPosts[post.reblog.id].__BOOSTERS.add(post.account);
} else {
boostedPosts[post.reblog.id].__BOOSTERS = new Set([post.account]);
}
return false;
} else {
boostedPosts[post.reblog.id] = post;
}
}
return true;
});
if (selectedAuthor && authorCountsMap.has(selectedAuthor)) {
filteredPosts = filteredPosts.filter(
(post) => post.account.id === selectedAuthor,
(post) =>
post.account.id === selectedAuthor ||
[...(post.__BOOSTERS || [])].find((a) => a.id === selectedAuthor),
);
}
@ -1420,6 +1440,7 @@ const PostLine = memo(
_followedTags: isFollowedTags,
_filtered: filterInfo,
visibility,
__BOOSTERS,
} = post;
const isReplyTo = inReplyToId && inReplyToAccountId !== account.id;
const isFiltered = !!filterInfo;
@ -1453,7 +1474,12 @@ const PostLine = memo(
<Avatar
url={account.avatarStatic || account.avatar}
squircle={account.bot}
/>{' '}
/>
{__BOOSTERS?.size > 0
? [...__BOOSTERS].map((b) => (
<Avatar url={b.avatarStatic || b.avatar} squircle={b.bot} />
))
: ''}{' '}
<Icon icon="rocket" />{' '}
{/* <Avatar
url={reblog.account.avatarStatic || reblog.account.avatar}