Skip to content

Commit

Permalink
detect markdown changes before notifying
Browse files Browse the repository at this point in the history
  • Loading branch information
ElectronicBlueberry committed Jul 1, 2024
1 parent 9d601f8 commit edb81e2
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions client/src/components/Workflow/Editor/Actions/stepActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,23 @@ export class LazySetLabelAction extends LazyMutateStepAction<"label"> {
run() {
const markdown = this.stateStore.report.markdown ?? "";
const newMarkdown = replaceLabel(markdown, this.labelType, this.fromValue as string, this.toValue as string);
this.stateStore.report.markdown = newMarkdown;
this.toast(this.fromValue ?? "", this.toValue ?? "");

if (markdown !== newMarkdown) {
this.stateStore.report.markdown = newMarkdown;
this.toast(this.fromValue ?? "", this.toValue ?? "");
}
}

undo() {
super.undo();

const markdown = this.stateStore.report.markdown ?? "";
const newMarkdown = replaceLabel(markdown, this.labelType, this.toValue as string, this.fromValue as string);
this.stateStore.report.markdown = newMarkdown;
this.toast(this.toValue ?? "", this.fromValue ?? "");

if (markdown !== newMarkdown) {
this.stateStore.report.markdown = newMarkdown;
this.toast(this.toValue ?? "", this.fromValue ?? "");
}
}

redo() {
Expand Down Expand Up @@ -139,18 +145,23 @@ export class LazySetOutputLabelAction extends LazyMutateStepAction<"workflow_out
run() {
const markdown = this.stateStore.report.markdown ?? "";
const newMarkdown = replaceLabel(markdown, "output", this.fromLabel, this.toLabel);
this.stateStore.report.markdown = newMarkdown;
this.toast(this.fromLabel ?? "", this.toLabel ?? "");

if (newMarkdown !== markdown) {
this.stateStore.report.markdown = newMarkdown;
this.toast(this.fromLabel ?? "", this.toLabel ?? "");
}
}

undo() {
super.undo();

const markdown = this.stateStore.report.markdown ?? "";
const newMarkdown = replaceLabel(markdown, "output", this.toLabel, this.fromLabel);
this.stateStore.report.markdown = newMarkdown;

this.toast(this.toLabel ?? "", this.fromLabel ?? "");
if (newMarkdown !== markdown) {
this.stateStore.report.markdown = newMarkdown;
this.toast(this.toLabel ?? "", this.fromLabel ?? "");
}
}

redo() {
Expand Down

0 comments on commit edb81e2

Please sign in to comment.