diff options
Diffstat (limited to 'src/client/views/nodes')
-rw-r--r-- | src/client/views/nodes/imageEditor/ImageEditor.tsx | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/client/views/nodes/imageEditor/ImageEditor.tsx b/src/client/views/nodes/imageEditor/ImageEditor.tsx index b56490bc3..1f38ff81a 100644 --- a/src/client/views/nodes/imageEditor/ImageEditor.tsx +++ b/src/client/views/nodes/imageEditor/ImageEditor.tsx @@ -26,6 +26,7 @@ import { CutMode, CursorData, ImageDimensions, ImageEditTool, ImageToolType, Poi import { DocumentView } from '../DocumentView'; import { SettingsManager } from '../../../util/SettingsManager'; import { Upload } from '../../../../server/SharedMediaTypes'; +import { DrawingFillHandler } from '../../smartdraw/DrawingFillHandler'; interface GenerativeFillProps { imageEditorOpen: boolean; @@ -301,12 +302,16 @@ const ImageEditor = ({ imageEditorOpen, imageEditorSource, imageRootDoc, addDoc }; if (useFirefly) { const res = await Networking.PostFormToServer(input || 'Fill in the image in the same style', imgBlob, maskBlob, img.width, img.height); - if (!res.ok) throw new Error(await res.text()); - const json = (await res.json()) as APISuccess; - imgUrls = json.urls ?? []; + + const error = ('error' in res && (res.error as string)) || ''; + if (error.includes('Dropbox') && confirm('Create image failed. Try authorizing DropBox?\r\n' + error.replace(/^[^"]*/, ''))) { + DrawingFillHandler.authorizeDropbox(); + } else { + imgUrls = (res as { urls: string[] }).urls ?? []; + } } else { const res = await ImageUtility.getEdit(imgBlob, maskBlob, input || 'Fill in the image in the same style', 2); - if (res.status == 'error') throw new Error(res.message); + if (res.status === 'error') throw new Error(res.message); const json = res as APISuccess; imgUrls = await Promise.all((json.urls ?? []).map(url => ImageUtility.convertImgToCanvasUrl(url, canvasDims.width, canvasDims.height))); } |