Add '- Boosts' filter

This commit is contained in:
Lim Chee Aun 2023-04-04 11:01:53 +08:00
parent 0ee17395ae
commit 8ce8e06913

View file

@ -19,6 +19,7 @@ function AccountStatuses() {
const { id, ...params } = useParams(); const { id, ...params } = useParams();
const [searchParams, setSearchParams] = useSearchParams(); const [searchParams, setSearchParams] = useSearchParams();
const excludeReplies = !searchParams.get('replies'); const excludeReplies = !searchParams.get('replies');
const excludeBoosts = !!searchParams.get('boosts');
const tagged = searchParams.get('tagged'); const tagged = searchParams.get('tagged');
const media = !!searchParams.get('media'); const media = !!searchParams.get('media');
const { masto, instance, authenticated } = api({ instance: params.instance }); const { masto, instance, authenticated } = api({ instance: params.instance });
@ -52,6 +53,7 @@ function AccountStatuses() {
accountStatusesIterator.current = masto.v1.accounts.listStatuses(id, { accountStatusesIterator.current = masto.v1.accounts.listStatuses(id, {
limit: LIMIT, limit: LIMIT,
exclude_replies: excludeReplies, exclude_replies: excludeReplies,
exclude_reblogs: excludeBoosts,
only_media: media, only_media: media,
tagged, tagged,
}); });
@ -102,7 +104,7 @@ function AccountStatuses() {
const filterBarRef = useRef(); const filterBarRef = useRef();
const TimelineStart = useMemo(() => { const TimelineStart = useMemo(() => {
const cachedAccount = snapStates.accounts[`${id}@${instance}`]; const cachedAccount = snapStates.accounts[`${id}@${instance}`];
const filtered = !excludeReplies || tagged || media; const filtered = !excludeReplies || excludeBoosts || tagged || media;
return ( return (
<> <>
<AccountInfo <AccountInfo
@ -130,6 +132,12 @@ function AccountStatuses() {
> >
+ Replies + Replies
</Link> </Link>
<Link
to={`/${instance}/a/${id}${excludeBoosts ? '' : '?boosts=0'}`}
class={!excludeBoosts ? '' : 'is-active'}
>
- Boosts
</Link>
<Link <Link
to={`/${instance}/a/${id}${media ? '' : '?media=1'}`} to={`/${instance}/a/${id}${media ? '' : '?media=1'}`}
class={media ? 'is-active' : ''} class={media ? 'is-active' : ''}
@ -163,6 +171,7 @@ function AccountStatuses() {
instance, instance,
authenticated, authenticated,
excludeReplies, excludeReplies,
excludeBoosts,
featuredTags, featuredTags,
tagged, tagged,
media, media,
@ -180,7 +189,7 @@ function AccountStatuses() {
(filterBarRef.current.offsetWidth - active.offsetWidth) / 2, (filterBarRef.current.offsetWidth - active.offsetWidth) / 2,
}); });
} }
}, [featuredTags, tagged, media, excludeReplies]); }, [featuredTags, tagged, media, excludeReplies, excludeBoosts]);
return ( return (
<Timeline <Timeline
@ -214,7 +223,7 @@ function AccountStatuses() {
useItemID useItemID
boostsCarousel={snapStates.settings.boostsCarousel} boostsCarousel={snapStates.settings.boostsCarousel}
timelineStart={TimelineStart} timelineStart={TimelineStart}
refresh={excludeReplies + tagged + media} refresh={excludeReplies + excludeBoosts + tagged + media}
/> />
); );
} }