Skip to content

Commit

Permalink
Updated UndoUtils.ts and modified 'Workspace.ts'
Browse files Browse the repository at this point in the history
  • Loading branch information
kghs-aver committed Dec 9, 2024
1 parent 25f49f4 commit 0073939
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
9 changes: 8 additions & 1 deletion ArduinoFrontend/src/app/Libs/UndoUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions ArduinoFrontend/src/app/Libs/Workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -720,6 +720,7 @@ export class Workspace {
obj.load(comp);
}
}
UndoUtils.resetStacks();

}
}
Expand Down Expand Up @@ -792,6 +793,7 @@ export class Workspace {
}
Workspace.circuitLoaded = true;
Workspace.circuitLoadStatus.emit(true);
UndoUtils.resetStacks();
}

/** Function to delete component fro Workspace */
Expand Down

0 comments on commit 0073939

Please sign in to comment.