diff --git a/assets/javascripts/discourse/components/modal/diff-modal.gjs b/assets/javascripts/discourse/components/modal/diff-modal.gjs index dc29b7ed..8eea2fd9 100644 --- a/assets/javascripts/discourse/components/modal/diff-modal.gjs +++ b/assets/javascripts/discourse/components/modal/diff-modal.gjs @@ -114,8 +114,7 @@ export default class ModalDiffModal extends Component { @action async suggestChanges() { - this.smoothStreamer.resetStreaming(); - this.diffStreamer.reset(); + this.#resetState(); try { this.loading = true; @@ -159,11 +158,25 @@ export default class ModalDiffModal extends Component { } } + @action + cleanupAndClose() { + this.#resetState(); + this.loading = false; + this.args.closeModal(); + } + + #resetState() { + this.suggestion = ""; + this.finalResult = ""; + this.smoothStreamer.resetStreaming(); + this.diffStreamer.reset(); + } +