slight cleanup

This commit is contained in:
Steve Ruiz 2023-11-25 19:52:11 +00:00
parent d1565789fd
commit edc01c7dae
2 changed files with 22 additions and 15 deletions

View File

@ -158,7 +158,7 @@ export class LiveImageShapeUtil extends ShapeUtil<LiveImageShape> {
useFal(shape.id, { useFal(shape.id, {
debounceTime: 0, debounceTime: 0,
appId: '110602490-lcm-sd15-i2i', appId: '110602490-lcm-plexed-sd15-i2i',
}) })
const bounds = this.editor.getShapeGeometry(shape).bounds const bounds = this.editor.getShapeGeometry(shape).bounds

View File

@ -71,10 +71,11 @@ export function useFal(
clientOnly: false, clientOnly: false,
throttleInterval: 1000, throttleInterval: 1000,
onError: (error) => { onError: (error) => {
console.log(`Received error!`)
console.error(error) console.error(error)
}, },
onResult: (result) => { onResult: (result) => {
console.log(result) console.log(`Received result!`)
if (result.images && result.images[0]) { if (result.images && result.images[0]) {
updateImage(result.images[0].url) updateImage(result.images[0].url)
} }
@ -99,6 +100,7 @@ export function useFal(
darkMode: editor.user.getIsDarkMode(), darkMode: editor.user.getIsDarkMode(),
}) })
if (!svg) { if (!svg) {
console.error('No SVG')
updateImage('') updateImage('')
return return
} }
@ -112,6 +114,7 @@ export function useFal(
scale: 1, scale: 1,
}) })
if (!image) { if (!image) {
console.error('No image')
updateImage('') updateImage('')
return return
} }
@ -126,18 +129,22 @@ export function useFal(
// We might be stale // We might be stale
if (iteration <= finishedIteration.current) return if (iteration <= finishedIteration.current) return
console.log('ok here we go') try {
sendCurrentData( console.log('Sending data...')
JSON.stringify({ sendCurrentData(
prompt, JSON.stringify({
image_url: imageDataUri, prompt,
sync_mode: true, image_url: imageDataUri,
strength: 0.7, sync_mode: true,
seed: 11252023, // TODO make this configurable in the UI strength: 0.7,
enable_safety_checks: false, seed: 11252023, // TODO make this configurable in the UI
}) enable_safety_checks: false,
) })
finishedIteration.current = iteration )
finishedIteration.current = iteration
} catch (e) {
console.error(e)
}
} }
const onDrawingChange = debounceTime const onDrawingChange = debounceTime
@ -149,7 +156,7 @@ export function useFal(
editor.on('update-drawings' as any, onDrawingChange) editor.on('update-drawings' as any, onDrawingChange)
return () => { return () => {
close() // close()
editor.off('update-drawings' as any, onDrawingChange) editor.off('update-drawings' as any, onDrawingChange)
} }
}, [editor, shapeId, throttleTime, debounceTime, appId]) }, [editor, shapeId, throttleTime, debounceTime, appId])