Skip to content

Commit

Permalink
Merge pull request #546 from kghs-aver/develop
Browse files Browse the repository at this point in the history
undo stack reset for circuit from gallery
  • Loading branch information
firuza authored Dec 24, 2024
2 parents 25f49f4 + 0485a71 commit 09ce073
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 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
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

0 comments on commit 09ce073

Please sign in to comment.