Fix undo history of moves and post-deploy handling

undo-history-fix
Nick O'Leary 2024-04-23 22:29:42 +02:00
parent 960af87fb0
commit c294532152
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
2 changed files with 29 additions and 4 deletions

View File

@ -706,11 +706,36 @@ RED.history = (function() {
}
function markEventDirty (evt) {
// This isn't 100% thorough - just covers the main move/edit/delete cases
evt.dirty = true
if (evt.multi) {
for (let i = 0; i < evt.events.length-1; i++) {
markEventDirty(evt.events[i])
}
} else if (evt.t === 'move') {
for (let i=0;i<evt.nodes.length;i++) {
evt.nodes[i].moved = true
}
} else if (evt.t === 'edit') {
evt.changed = true
} else if (evt.t === 'delete') {
if (evt.nodes) {
for (let i=0;i<evt.nodes.length;i++) {
evt.nodes[i].changed = true
}
}
}
}
return {
//TODO: this function is a placeholder until there is a 'save' event that can be listened to
markAllDirty: function() {
for (var i=0;i<undoHistory.length;i++) {
// A deploy has happened meaning any undo into the history will represent
// an undeployed change - regardless of what it was when the event was recorded.
// This goes back through the history any marks them all as being dirty events
// and also ensures individual node states are marked dirty
for (let i=0;i<undoHistory.length;i++) {
undoHistory[i].dirty = true;
markEventDirty(undoHistory[i])
}
},
list: function() {

View File

@ -2167,9 +2167,9 @@ RED.view = (function() {
if (n.ox !== n.n.x || n.oy !== n.n.y || addedToGroup) {
// This node has moved or added to a group
if (rehomedNodes.has(n)) {
moveAndChangedGroupEvent.nodes.push({...n})
moveAndChangedGroupEvent.nodes.push({...n, moved: n.n.moved})
} else {
moveEvent.nodes.push({...n})
moveEvent.nodes.push({...n, moved: n.n.moved})
}
n.n.dirty = true;
n.n.moved = true;