chore(SW-663): updated @contentstack/live-preview-utils to latest
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user