Clear context contents when switching projects

Fixes #3240
This commit is contained in:
Nick O'Leary
2021-11-02 00:12:30 +00:00
parent 30b00741b5
commit 3abef972a7
4 changed files with 124 additions and 28 deletions

View File

@@ -378,15 +378,23 @@ function getActiveProject(user) {
}
function reloadActiveProject(action) {
// Stop the current flows
return runtime.nodes.stopFlows().then(function() {
return runtime.nodes.loadFlows(true).then(function() {
events.emit("runtime-event",{id:"project-update", payload:{ project: activeProject.name, action:action}});
}).catch(function(err) {
// We're committed to the project change now, so notify editors
// that it has changed.
events.emit("runtime-event",{id:"project-update", payload:{ project: activeProject.name, action:action}});
throw err;
});
// Reset context to remove any old values
return runtime.nodes.clearContext().then(function() {
// Load the new project flows and start them
return runtime.nodes.loadFlows(true).then(function() {
events.emit("runtime-event",{id:"project-update", payload:{ project: activeProject.name, action:action}});
}).catch(function(err) {
// We're committed to the project change now, so notify editors
// that it has changed.
events.emit("runtime-event",{id:"project-update", payload:{ project: activeProject.name, action:action}});
throw err;
});
})
}).catch(function(err) {
console.log(err.stack);
throw err;
});
}
function createProject(user, metadata) {