mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-02-15 16:02:32 +08:00
Prevent cleaning graph state on undo/redo
This commit is contained in:
parent
57926635e8
commit
f7aa4c0e9b
@ -71,24 +71,27 @@ function graphEqual(a, b, root = true) {
|
||||
}
|
||||
|
||||
const undoRedo = async (e) => {
|
||||
const updateState = async (source, target) => {
|
||||
const prevState = source.pop();
|
||||
if (prevState) {
|
||||
target.push(activeState);
|
||||
isOurLoad = true;
|
||||
// Pause rendering to decrease graph flicker
|
||||
app.canvas.stopRendering();
|
||||
try {
|
||||
await app.loadGraphData(prevState, false);
|
||||
activeState = prevState;
|
||||
} finally {
|
||||
app.canvas.startRendering();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (e.ctrlKey || e.metaKey) {
|
||||
if (e.key === "y") {
|
||||
const prevState = redo.pop();
|
||||
if (prevState) {
|
||||
undo.push(activeState);
|
||||
isOurLoad = true;
|
||||
await app.loadGraphData(prevState);
|
||||
activeState = prevState;
|
||||
}
|
||||
updateState(redo, undo);
|
||||
return true;
|
||||
} else if (e.key === "z") {
|
||||
const prevState = undo.pop();
|
||||
if (prevState) {
|
||||
redo.push(activeState);
|
||||
isOurLoad = true;
|
||||
await app.loadGraphData(prevState);
|
||||
activeState = prevState;
|
||||
}
|
||||
updateState(undo, redo);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1559,9 +1559,12 @@ export class ComfyApp {
|
||||
/**
|
||||
* Populates the graph with the specified workflow data
|
||||
* @param {*} graphData A serialized graph object
|
||||
* @param { boolean } clean If the graph state, e.g. images, should be cleared
|
||||
*/
|
||||
async loadGraphData(graphData) {
|
||||
this.clean();
|
||||
async loadGraphData(graphData, clean = true) {
|
||||
if (clean !== false) {
|
||||
this.clean();
|
||||
}
|
||||
|
||||
let reset_invalid_values = false;
|
||||
if (!graphData) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user