Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undo stack reset for circuit from gallery #546

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
7 changes: 3 additions & 4 deletions ArduinoFrontend/src/app/Libs/Workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -687,8 +687,7 @@ 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,7 +719,6 @@ export class Workspace {
obj.load(comp);
}
}

}
}
// Wait until all components are drawn
Expand All @@ -733,7 +731,7 @@ export class Workspace {
window.hideLoading();
}
}, 100);

UndoUtils.resetStacks();
}
/** This function recreates the wire object */
static LoadWires(wires: any[], retainId = false, pushUndo = false) {
Expand Down Expand Up @@ -792,6 +790,7 @@ export class Workspace {
}
Workspace.circuitLoaded = true;
Workspace.circuitLoadStatus.emit(true);
UndoUtils.resetStacks();
}

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