fix: hidden post

This commit is contained in:
gosangam
2026-06-16 00:05:07 +05:30
parent 197e13c0ef
commit 5c72416ae8
4 changed files with 67 additions and 6 deletions
@@ -0,0 +1,29 @@
"use client";
/**
* HiddenCountContext — lets a hide/unhide action deep in the tree (the
* PostCardMenu) nudge the owner's hidden-post count held by the /u/me layout,
* so the "Hidden" tab appears/disappears instantly without a refetch.
*
* The /u/me layout provides it around its subtree. Anywhere else (home feed,
* other users' profiles) there's no provider, so `adjustHiddenCount` defaults
* to a no-op — hiding from those surfaces simply doesn't touch a tab that
* isn't there.
*/
import { createContext, useContext } from "react";
type HiddenCountValue = {
/** Adjust the owner's hidden-post count by `delta` (the layout clamps at 0). */
adjustHiddenCount: (delta: number) => void;
};
const HiddenCountContext = createContext<HiddenCountValue>({
adjustHiddenCount: () => {},
});
export const HiddenCountProvider = HiddenCountContext.Provider;
export function useHiddenCount(): HiddenCountValue {
return useContext(HiddenCountContext);
}