Unverified Commit edb81e25 authored by Laila Los's avatar Laila Los
Browse files

detect markdown changes before notifying

parent 9d601f8c
Loading
Loading
Loading
Loading
+19 −8
Original line number Diff line number Diff line
@@ -87,18 +87,24 @@ 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);

        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);

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

    redo() {
        super.redo();
@@ -139,19 +145,24 @@ export class LazySetOutputLabelAction extends LazyMutateStepAction<"workflow_out
    run() {
        const markdown = this.stateStore.report.markdown ?? "";
        const newMarkdown = replaceLabel(markdown, "output", 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;

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

    redo() {
        this.run();