aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/imageEditor/ImageEditor.tsx
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2025-08-11 13:04:26 -0400
committerbobzel <zzzman@gmail.com>2025-08-11 13:04:26 -0400
commit5b0b7241e68febc2d0556b6c2e8349411b5c12a0 (patch)
treee4ee96e10ad16cff290f86108d160ec93575fc03 /src/client/views/nodes/imageEditor/ImageEditor.tsx
parentb3aa4a5b0bbbb87d041b9515bddedbcbf8ae9fc5 (diff)
fixed image fill api to handler errors better.
Diffstat (limited to 'src/client/views/nodes/imageEditor/ImageEditor.tsx')
-rw-r--r--src/client/views/nodes/imageEditor/ImageEditor.tsx13
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)));
}