From d675da23c472d50379cfb5b0e048d82521550979 Mon Sep 17 00:00:00 2001 From: kghs-aver Date: Mon, 9 Dec 2024 15:46:26 +0630 Subject: [PATCH] Reset undo stack fro circuit import Updated `UndoUtils.ts` and modified 'Workspace.ts' --- ArduinoFrontend/src/app/Libs/UndoUtils.ts | 16 ++++++++-------- ArduinoFrontend/src/app/Libs/Workspace.ts | 4 +--- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/ArduinoFrontend/src/app/Libs/UndoUtils.ts b/ArduinoFrontend/src/app/Libs/UndoUtils.ts index ba769afe..0425e1de 100644 --- a/ArduinoFrontend/src/app/Libs/UndoUtils.ts +++ b/ArduinoFrontend/src/app/Libs/UndoUtils.ts @@ -50,14 +50,14 @@ export abstract class UndoUtils { this.loadChange(cng, 'redo'); } } - /** - * Resets the undo and redo stacks - */ - static resetStacks() { - UndoUtils.undo = []; // Clear undo stack - UndoUtils.redo = []; // Clear redo stack - console.log('Undo and redo stacks have been reset.'); - } + /** + * Resets the undo and redo stacks + */ + static resetStacks() { + UndoUtils.undo = []; // Clear undo stack + UndoUtils.redo = []; // Clear redo stack + console.log('Undo and redo stacks have been reset.'); + } /** * Function to reset redo stack & push into undo stack * @param ele event snapshot diff --git a/ArduinoFrontend/src/app/Libs/Workspace.ts b/ArduinoFrontend/src/app/Libs/Workspace.ts index b04d7ebf..8a7bc0ef 100644 --- a/ArduinoFrontend/src/app/Libs/Workspace.ts +++ b/ArduinoFrontend/src/app/Libs/Workspace.ts @@ -720,8 +720,6 @@ export class Workspace { obj.load(comp); } } - UndoUtils.resetStacks(); - } } // Wait until all components are drawn @@ -734,7 +732,7 @@ export class Workspace { window.hideLoading(); } }, 100); - + UndoUtils.resetStacks(); } /** This function recreates the wire object */ static LoadWires(wires: any[], retainId = false, pushUndo = false) {