fix: refresh favorites after unfavorite
This commit is contained in:
@@ -83,14 +83,18 @@ function RankBadge({ index }: { index: number }) {
|
||||
);
|
||||
}
|
||||
|
||||
function PopularRankRow({
|
||||
export function PopularRankRow({
|
||||
post,
|
||||
index,
|
||||
categories,
|
||||
browseSort = "popular",
|
||||
onFavoriteChange,
|
||||
}: {
|
||||
post: Post;
|
||||
index: number;
|
||||
categories: Category[];
|
||||
browseSort?: string;
|
||||
onFavoriteChange?: (postId: string, favorited: boolean) => void;
|
||||
}) {
|
||||
const { t, lang } = useI18n();
|
||||
const navigate = useNavigate();
|
||||
@@ -126,11 +130,12 @@ function PopularRankRow({
|
||||
<article className="relative flex items-center gap-3 overflow-hidden rounded-2xl bg-[#272632] p-3 transition hover:ring-1 hover:ring-ark-gold/55 md:h-[90px] md:gap-0 md:p-0">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() =>
|
||||
navigate(
|
||||
lp(`/browse?sort=popular&post=${encodeURIComponent(post.id)}`),
|
||||
)
|
||||
}
|
||||
onClick={() => {
|
||||
const params = new URLSearchParams();
|
||||
if (browseSort) params.set("sort", browseSort);
|
||||
params.set("post", post.id);
|
||||
navigate(lp(`/browse?${params.toString()}`));
|
||||
}}
|
||||
aria-label={r.title}
|
||||
className="absolute inset-0 z-0 rounded-2xl outline-none focus-visible:ring-2 focus-visible:ring-ark-gold/70"
|
||||
/>
|
||||
@@ -175,7 +180,12 @@ function PopularRankRow({
|
||||
</div>
|
||||
|
||||
<div className="relative z-10 flex shrink-0 items-center gap-2 pr-4 md:pr-6">
|
||||
<FavoriteButton resourceId={r.id} />
|
||||
<FavoriteButton
|
||||
resourceId={r.id}
|
||||
onFavoriteChange={(favorited) =>
|
||||
onFavoriteChange?.(post.id, favorited)
|
||||
}
|
||||
/>
|
||||
{r.isDownloadable ? (
|
||||
<button
|
||||
type="button"
|
||||
|
||||
Reference in New Issue
Block a user