diff options
Diffstat (limited to 'src/client/views/smartdraw/SmartDrawHandler.tsx')
| -rw-r--r-- | src/client/views/smartdraw/SmartDrawHandler.tsx | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/client/views/smartdraw/SmartDrawHandler.tsx b/src/client/views/smartdraw/SmartDrawHandler.tsx index 489f6f92b..ca65ea388 100644 --- a/src/client/views/smartdraw/SmartDrawHandler.tsx +++ b/src/client/views/smartdraw/SmartDrawHandler.tsx @@ -99,7 +99,7 @@ export class SmartDrawHandler extends ObservableReactComponent<{}> { @action displayRegenerate = (x: number, y: number, addFunc: (strokeData: [InkData, string, string][], opts: DrawingOptions, gptRes: string, containerDoc?: Doc) => void, deleteFunc: (doc?: Doc) => void) => { - this._selectedDoc = DocumentView.SelectedDocs().lastElement(); + this._selectedDoc = DocumentView.SelectedDocs()?.lastElement(); const docData = this._selectedDoc[DocData]; this._addFunc = addFunc; this._deleteFunc = deleteFunc; @@ -123,7 +123,6 @@ export class SmartDrawHandler extends ObservableReactComponent<{}> { this._size = 350; this._autoColor = true; Doc.ActiveTool = InkTool.None; - this._lastInput = { text: '', complexity: 5, size: 350, autoColor: true, x: 0, y: 0 }; }; @action @@ -154,8 +153,6 @@ export class SmartDrawHandler extends ObservableReactComponent<{}> { } else { this._showOptions = false; await this.drawWithGPT({ X: this._pageX, Y: this._pageY }, this._userInput, this._complexity, this._size, this._autoColor); - this.hideSmartDrawHandler(); - this._showRegenerate = true; } this._isLoading = false; this._canInteract = true; @@ -176,6 +173,8 @@ export class SmartDrawHandler extends ObservableReactComponent<{}> { console.log(res); const strokeData = await this.parseResponse(res, startPt, false, autoColor); this._errorOccurredOnce = false; + this.hideSmartDrawHandler(); + this._showRegenerate = true; return strokeData; } catch (err) { if (this._errorOccurredOnce) { @@ -239,7 +238,7 @@ export class SmartDrawHandler extends ObservableReactComponent<{}> { }); if (regenerate) { if (this._deleteFunc !== unimplementedFunction) this._deleteFunc(this._selectedDoc); - this._addFunc(strokeData, this._lastInput, svg[0], this._selectedDoc); + this._addFunc(strokeData, this._lastInput, svg[0]); } else { this._addFunc(strokeData, this._lastInput, svg[0]); } |
