Hide banner for interior admin pages

This commit is contained in:
Sam Becker 2024-04-28 11:23:55 -05:00
parent 1f0f9aa906
commit 72dd044c83
2 changed files with 8 additions and 2 deletions

View File

@ -6,6 +6,7 @@ import {
PATH_ADMIN_CONFIGURATION,
checkPathPrefix,
isPathAdminConfiguration,
isPathTopLevelAdmin,
} from '@/site/paths';
import { useAppState } from '@/state/AppState';
import { clsx } from 'clsx/lite';
@ -39,17 +40,19 @@ export default function AdminNavClient({
.concat(adminUpdateTimes)
, [mostRecentPhotoUpdateTime, adminUpdateTimes]);
const [shouldShowBanner, setShouldShowBanner] =
const [hasRecentUpdates, setHasRecentUpdates] =
useState(areTimesRecent(updateTimes));
useEffect(() => {
// Check every 10 seconds if update times are recent
const timeout = setTimeout(() =>
setShouldShowBanner(areTimesRecent(updateTimes))
setHasRecentUpdates(areTimesRecent(updateTimes))
, 10_000);
return () => clearTimeout(timeout);
}, [updateTimes]);
const shouldShowBanner = hasRecentUpdates && isPathTopLevelAdmin(pathname);
return (
<SiteGrid
contentMain={

View File

@ -241,6 +241,9 @@ export const isPathSignIn = (pathname?: string) =>
export const isPathAdmin = (pathname?: string) =>
checkPathPrefix(pathname, PATH_ADMIN);
export const isPathTopLevelAdmin = (pathname?: string) =>
PATHS_ADMIN.some(path => path === pathname);
export const isPathAdminConfiguration = (pathname?: string) =>
checkPathPrefix(pathname, PATH_ADMIN_CONFIGURATION);