fix: hidden post
This commit is contained in:
@@ -38,6 +38,7 @@ import {
|
||||
} from "@/lib/social";
|
||||
import { useAuth } from "@/components/auth/auth-provider";
|
||||
import { useAuthGate } from "@/components/auth/auth-gate";
|
||||
import { useHiddenCount } from "@/components/profile/hidden-count-context";
|
||||
import { useMediaQuery } from "@/components/selection-toolbar/shared";
|
||||
import { ConfirmModal } from "@/components/ui/confirm-modal";
|
||||
import { ReportDialog, type ReportOption } from "@/components/social/report-dialog";
|
||||
@@ -78,6 +79,8 @@ export function PostCardMenu({
|
||||
}) {
|
||||
const { user, loading } = useAuth();
|
||||
const { requireAuth } = useAuthGate();
|
||||
// No-op outside the /u/me layout; there, it toggles the "Hidden" tab live.
|
||||
const { adjustHiddenCount } = useHiddenCount();
|
||||
const isMobile = useMediaQuery("(max-width: 767px)");
|
||||
const [open, setOpen] = useState(false);
|
||||
const [blockOpen, setBlockOpen] = useState(false);
|
||||
@@ -219,6 +222,8 @@ export function PostCardMenu({
|
||||
setOpen(false);
|
||||
const next = !hidden;
|
||||
setHidden(next); // optimistic
|
||||
// Optimistically toggle the owner's "Hidden" tab via the layout context.
|
||||
adjustHiddenCount(next ? 1 : -1);
|
||||
try {
|
||||
if (next) await posts.hide(post.id);
|
||||
else await posts.unhide(post.id);
|
||||
@@ -228,6 +233,7 @@ export function PostCardMenu({
|
||||
onHiddenChange?.(post.id, next);
|
||||
} catch {
|
||||
setHidden(!next); // revert
|
||||
adjustHiddenCount(next ? -1 : 1); // revert the tab count too
|
||||
toast.error("Could not update post visibility");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user