Hide banner for interior admin pages
This commit is contained in:
parent
1f0f9aa906
commit
72dd044c83
@ -6,6 +6,7 @@ import {
|
|||||||
PATH_ADMIN_CONFIGURATION,
|
PATH_ADMIN_CONFIGURATION,
|
||||||
checkPathPrefix,
|
checkPathPrefix,
|
||||||
isPathAdminConfiguration,
|
isPathAdminConfiguration,
|
||||||
|
isPathTopLevelAdmin,
|
||||||
} from '@/site/paths';
|
} from '@/site/paths';
|
||||||
import { useAppState } from '@/state/AppState';
|
import { useAppState } from '@/state/AppState';
|
||||||
import { clsx } from 'clsx/lite';
|
import { clsx } from 'clsx/lite';
|
||||||
@ -39,17 +40,19 @@ export default function AdminNavClient({
|
|||||||
.concat(adminUpdateTimes)
|
.concat(adminUpdateTimes)
|
||||||
, [mostRecentPhotoUpdateTime, adminUpdateTimes]);
|
, [mostRecentPhotoUpdateTime, adminUpdateTimes]);
|
||||||
|
|
||||||
const [shouldShowBanner, setShouldShowBanner] =
|
const [hasRecentUpdates, setHasRecentUpdates] =
|
||||||
useState(areTimesRecent(updateTimes));
|
useState(areTimesRecent(updateTimes));
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Check every 10 seconds if update times are recent
|
// Check every 10 seconds if update times are recent
|
||||||
const timeout = setTimeout(() =>
|
const timeout = setTimeout(() =>
|
||||||
setShouldShowBanner(areTimesRecent(updateTimes))
|
setHasRecentUpdates(areTimesRecent(updateTimes))
|
||||||
, 10_000);
|
, 10_000);
|
||||||
return () => clearTimeout(timeout);
|
return () => clearTimeout(timeout);
|
||||||
}, [updateTimes]);
|
}, [updateTimes]);
|
||||||
|
|
||||||
|
const shouldShowBanner = hasRecentUpdates && isPathTopLevelAdmin(pathname);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SiteGrid
|
<SiteGrid
|
||||||
contentMain={
|
contentMain={
|
||||||
|
|||||||
@ -241,6 +241,9 @@ export const isPathSignIn = (pathname?: string) =>
|
|||||||
export const isPathAdmin = (pathname?: string) =>
|
export const isPathAdmin = (pathname?: string) =>
|
||||||
checkPathPrefix(pathname, PATH_ADMIN);
|
checkPathPrefix(pathname, PATH_ADMIN);
|
||||||
|
|
||||||
|
export const isPathTopLevelAdmin = (pathname?: string) =>
|
||||||
|
PATHS_ADMIN.some(path => path === pathname);
|
||||||
|
|
||||||
export const isPathAdminConfiguration = (pathname?: string) =>
|
export const isPathAdminConfiguration = (pathname?: string) =>
|
||||||
checkPathPrefix(pathname, PATH_ADMIN_CONFIGURATION);
|
checkPathPrefix(pathname, PATH_ADMIN_CONFIGURATION);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user