Hide banner for interior admin pages
This commit is contained in:
parent
1f0f9aa906
commit
72dd044c83
@ -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={
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user