aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/views/nodes/ImageBox.tsx24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/client/views/nodes/ImageBox.tsx b/src/client/views/nodes/ImageBox.tsx
index c3df82611..7ad3ee2b6 100644
--- a/src/client/views/nodes/ImageBox.tsx
+++ b/src/client/views/nodes/ImageBox.tsx
@@ -27,7 +27,7 @@ import { Networking } from '../../Network';
import { DragManager } from '../../util/DragManager';
import { SettingsManager } from '../../util/SettingsManager';
import { SnappingManager } from '../../util/SnappingManager';
-import { undoable, undoBatch } from '../../util/UndoManager';
+import { undoable, undoBatch, UndoManager } from '../../util/UndoManager';
import { CollectionFreeFormView } from '../collections/collectionFreeForm/CollectionFreeFormView';
import { ContextMenu } from '../ContextMenu';
import { ContextMenuProps } from '../ContextMenuItem';
@@ -367,7 +367,7 @@ export class ImageBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
@action
handlePromptChange = (val: string | number) => {
- this._outpaintPromptInput = val;
+ this._outpaintPromptInput = '' + val;
};
@action
@@ -392,19 +392,19 @@ export class ImageBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
// Set flag that outpainting is in progress
this._outpaintingInProgress = true;
+ // Revert dimensions if prompt is blank (acts like Cancel)
+ if (!customPrompt) {
+ this.Document._width = origWidth;
+ this.Document._height = origHeight;
+ this._outpaintingInProgress = false;
+ return;
+ }
+
try {
const currentPath = this.choosePath(field.url);
const newWidth = NumCast(this.Document._width);
const newHeight = NumCast(this.Document._height);
- // Revert dimensions if prompt is blank (acts like Cancel)
- if (!customPrompt) {
- this.Document._width = origWidth;
- this.Document._height = origHeight;
- this._outpaintingInProgress = false;
- return;
- }
-
// Optional: add loading indicator
const loadingOverlay = document.createElement('div');
loadingOverlay.style.position = 'absolute';
@@ -426,6 +426,7 @@ export class ImageBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
newDimensions: { width: newWidth, height: newHeight },
});
+ const batch = UndoManager.StartBatch('outpaint image');
if (response && typeof response === 'object' && 'url' in response && typeof response.url === 'string') {
console.log('Received outpainted image:', response.url);
@@ -456,6 +457,7 @@ export class ImageBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
this.Document._height = origHeight;
alert('Failed to receive a valid image URL from server.');
}
+ batch.end();
this._mainCont?.removeChild(loadingOverlay);
} catch (error) {
@@ -464,7 +466,7 @@ export class ImageBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
this.Document._height = origHeight;
alert('An error occurred while outpainting. Please try again.');
} finally {
- this._outpaintingInProgress = false;
+ runInAction(() => (this._outpaintingInProgress = false));
}
};