chore(SW-663): updated @contentstack/live-preview-utils to latest

This commit is contained in:
Erik Tiekstra
2024-11-07 13:29:12 +01:00
parent 953f860e5d
commit d8751b3fea
8 changed files with 109 additions and 63 deletions

View File

@@ -5,7 +5,7 @@ interface PreviewData {
uid: string
}
const getRef = cache((): { current: PreviewData | undefined } => ({
const getRef = cache((): { current?: PreviewData } => ({
current: undefined,
}))
@@ -17,8 +17,7 @@ const getRef = cache((): { current: PreviewData | undefined } => ({
*
* @param hash
*/
export function setPreviewData(data: PreviewData | undefined) {
console.log("SETTING HASH")
export function setPreviewData(data?: PreviewData) {
getRef().current = data
}
@@ -32,11 +31,12 @@ export function getPreviewHash() {
/**
* Check if the current request is a preview by comparing the uid
*/
export function isPreview(uid?: string) {
export function isPreviewByUid(uid: string) {
const data = getRef().current
if (uid && data?.hash) {
if (data?.hash) {
return data.uid === uid
}
return false
}