29 lines
1.1 KiB
TypeScript
29 lines
1.1 KiB
TypeScript
"use client";
|
|
|
|
/**
|
|
* Whether the app's own chrome should step aside for the page.
|
|
*
|
|
* A chat thread is a full-height surface with its own header and a composer
|
|
* pinned to the bottom: the tab bar competes with the composer for the same
|
|
* edge, the hamburger duplicates a back button already on screen, and the
|
|
* wordmark header stacks a second title bar above the thread's own.
|
|
*
|
|
* One hook so the header, the nav, the hamburger and the layout's bottom
|
|
* padding can never disagree — if they did, hiding one would leave a gap
|
|
* where it used to be. The desktop sidebar is deliberately unaffected: it is
|
|
* the only way out of a thread on a wide screen.
|
|
*/
|
|
|
|
import { usePathname } from "next/navigation";
|
|
|
|
/**
|
|
* True on a thread itself (`/chats/<id>`) but NOT on the inbox or a chat's
|
|
* profile page: those are ordinary scrolling pages where the tab bar belongs.
|
|
*/
|
|
export function useHidesAppChrome(): boolean {
|
|
const pathname = usePathname();
|
|
if (!pathname?.startsWith("/chats/")) return false;
|
|
// "", "chats", "<id>" — anything deeper is a sub-page like /profile.
|
|
return pathname.split("/").filter(Boolean).length === 2;
|
|
}
|