From 00739397a0fe5f94ffb4c9af76cff0a930bbf71d Mon Sep 17 00:00:00 2001 From: kghs-aver Date: Mon, 9 Dec 2024 15:12:39 +0630 Subject: [PATCH 1/3] Updated `UndoUtils.ts` and modified 'Workspace.ts' --- ArduinoFrontend/src/app/Libs/UndoUtils.ts | 9 ++++++++- ArduinoFrontend/src/app/Libs/Workspace.ts | 6 ++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/ArduinoFrontend/src/app/Libs/UndoUtils.ts b/ArduinoFrontend/src/app/Libs/UndoUtils.ts index 550af18f..ba769afe 100644 --- a/ArduinoFrontend/src/app/Libs/UndoUtils.ts +++ b/ArduinoFrontend/src/app/Libs/UndoUtils.ts @@ -50,7 +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.'); + } /** * 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 f60ffadc..b04d7ebf 100644 --- a/ArduinoFrontend/src/app/Libs/Workspace.ts +++ b/ArduinoFrontend/src/app/Libs/Workspace.ts @@ -687,8 +687,8 @@ export class Workspace { ${Workspace.scale}) translate(${Workspace.translateX}, ${Workspace.translateY})`); - - // For each component key in the data + + // For each component key in the data for (const key in data) { // Check if key is valid if (!(key in data)) { @@ -720,6 +720,7 @@ export class Workspace { obj.load(comp); } } + UndoUtils.resetStacks(); } } @@ -792,6 +793,7 @@ export class Workspace { } Workspace.circuitLoaded = true; Workspace.circuitLoadStatus.emit(true); + UndoUtils.resetStacks(); } /** Function to delete component fro Workspace */ From d675da23c472d50379cfb5b0e048d82521550979 Mon Sep 17 00:00:00 2001 From: kghs-aver Date: Mon, 9 Dec 2024 15:46:26 +0630 Subject: [PATCH 2/3] 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) { From 0485a712f115edf51a536235b6aa0dbeddb03db4 Mon Sep 17 00:00:00 2001 From: kghs-aver Date: Tue, 10 Dec 2024 22:02:49 +0630 Subject: [PATCH 3/3] fixed linting error --- ArduinoFrontend/src/app/Libs/Workspace.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/ArduinoFrontend/src/app/Libs/Workspace.ts b/ArduinoFrontend/src/app/Libs/Workspace.ts index 8a7bc0ef..34870b34 100644 --- a/ArduinoFrontend/src/app/Libs/Workspace.ts +++ b/ArduinoFrontend/src/app/Libs/Workspace.ts @@ -687,7 +687,6 @@ export class Workspace { ${Workspace.scale}) translate(${Workspace.translateX}, ${Workspace.translateY})`); - // For each component key in the data for (const key in data) { // Check if key is valid