Skip to content

Commit

Permalink
fix: preview ping
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <i@innei.in>
  • Loading branch information
Innei committed Dec 23, 2023
1 parent 9eb7041 commit 5089ead
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/app/preview/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,25 @@ export default function PreviewPage() {
}

if (parsedData.type === 'preview') {
if (
JSON.stringify(jotaiStore.get(previewDataAtom)) ===
JSON.stringify(parsedData.data)
)
return
jotaiStore.set(previewDataAtom, simpleCamelcaseKeys(parsedData.data))
}
}
window.addEventListener('message', handler)

console.debug('preview page ready')
window.opener.postMessage('ok', targetOrigin)

const timer = setInterval(() => {
window.opener.postMessage('ok', targetOrigin)
}, 3000)
return () => {
window.removeEventListener('message', handler)
clearInterval(timer)
}
}, [])

Expand Down

1 comment on commit 5089ead

@vercel
Copy link

@vercel vercel bot commented on 5089ead Dec 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

shiro – ./

shiro-innei.vercel.app
shiro-git-main-innei.vercel.app
innei.in
springtide.vercel.app

Please sign in to comment.