diff --git a/apps/live-next/app/alert-banner.tsx b/apps/live-next/app/alert-banner.tsx index 225d7a0b2..7c0eb7902 100644 --- a/apps/live-next/app/alert-banner.tsx +++ b/apps/live-next/app/alert-banner.tsx @@ -1,20 +1,15 @@ 'use client' +import {useIsPresentationTool} from '@sanity/next-loader/hooks' import {useRouter} from 'next/navigation' -import {useSyncExternalStore, useTransition} from 'react' +import {useTransition} from 'react' import {disableDraftMode} from './actions' -const emptySubscribe = () => () => {} - export default function AlertBanner() { const router = useRouter() const [pending, startTransition] = useTransition() - const shouldShow = useSyncExternalStore( - emptySubscribe, - () => window.top === window, - () => false, - ) + const shouldShow = useIsPresentationTool() === false if (!shouldShow) return null diff --git a/apps/live-next/app/draft-mode-status.tsx b/apps/live-next/app/draft-mode-status.tsx index 05c32e047..bf09566d5 100644 --- a/apps/live-next/app/draft-mode-status.tsx +++ b/apps/live-next/app/draft-mode-status.tsx @@ -1,10 +1,18 @@ 'use client' -import {useDraftModeEnvironment, useDraftModePerspective} from '@sanity/next-loader/hooks' +import { + useDraftModeEnvironment, + useDraftModePerspective, + useIsLivePreview, +} from '@sanity/next-loader/hooks' export function DraftModeStatus() { + const isLivePreview = useIsLivePreview() const perspective = useDraftModePerspective() const environment = useDraftModeEnvironment() + + if (isLivePreview !== true) return null + return (

perspective: {perspective}

diff --git a/apps/live-next/app/layout.tsx b/apps/live-next/app/layout.tsx index d5ea5cba9..48f1b7786 100644 --- a/apps/live-next/app/layout.tsx +++ b/apps/live-next/app/layout.tsx @@ -80,12 +80,8 @@ export default async function RootLayout({children}: {children: React.ReactNode} >
- {(await draftMode()).isEnabled && ( - <> - - - - )} + {(await draftMode()).isEnabled && } +
{children}