Update useLiveImage.ts

This commit is contained in:
Steve Ruiz 2023-11-25 21:53:41 +00:00
parent f0e2ce1ce5
commit 1545f6c09e
1 changed files with 5 additions and 4 deletions

View File

@ -28,6 +28,7 @@ export function useLiveImage(
const finishedIteration = useRef<number>(0) const finishedIteration = useRef<number>(0)
const prevHash = useRef<string | null>(null) const prevHash = useRef<string | null>(null)
const prevPrompt = useRef<string>('')
useEffect(() => { useEffect(() => {
function updateImage(url: string | null) { function updateImage(url: string | null) {
@ -88,11 +89,11 @@ export function useLiveImage(
.filter((id) => id !== shapeId) .filter((id) => id !== shapeId)
.map((id) => editor.getShape(id)) as TLShape[] .map((id) => editor.getShape(id)) as TLShape[]
const hash = getHashForObject(shapes)
if (hash === prevHash.current) return
prevHash.current = hash
const shape = editor.getShape<LiveImageShape>(shapeId)! const shape = editor.getShape<LiveImageShape>(shapeId)!
const hash = getHashForObject(shapes)
if (hash === prevHash.current && shape.props.name === prevPrompt.current) return
prevHash.current = hash
prevPrompt.current = shape.props.name
const svg = await editor.getSvg([shape], { const svg = await editor.getSvg([shape], {
background: true, background: true,