diff --git a/DesignSpace/Workspace/FunctionLibraries/OnFocus.js b/DesignSpace/Workspace/FunctionLibraries/OnFocus.js index 21596fb7c..716114348 100644 --- a/DesignSpace/Workspace/FunctionLibraries/OnFocus.js +++ b/DesignSpace/Workspace/FunctionLibraries/OnFocus.js @@ -5,9 +5,9 @@ function newOnFocus () { return thisObject function getNodeThatIsOnFocus (node) { - if (node === undefined) { return } + if (node === undefined || node === null) { return } if (node.payload === undefined) { return } - let nodeDefinition = getNodeDefinition (node) + let nodeDefinition = getNodeDefinition(node) if (nodeDefinition !== undefined) { /* First we ask the question to ourself */ if (node.payload.uiObject.isOnFocus === true) { diff --git a/DesignSpace/Workspace/Workspace.js b/DesignSpace/Workspace/Workspace.js index 4cd40ff89..5f1c80761 100644 --- a/DesignSpace/Workspace/Workspace.js +++ b/DesignSpace/Workspace/Workspace.js @@ -67,6 +67,7 @@ function newWorkspace () { thisObject.nodeChildren = newNodeChildren() + let isInitialized = false let workingAtTask = 0 let circularProgressBar = newBusyProgressBar() circularProgressBar.fitFunction = canvas.floatingSpace.fitIntoVisibleArea @@ -118,6 +119,7 @@ function newWorkspace () { canvas.cockpitSpace.initializePosition() canvas.splashScreen.initialize() setInterval(saveWorkspace, 60000) + isInitialized = true } } catch (err) { if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err = ' + err.stack) } @@ -186,17 +188,10 @@ function newWorkspace () { } function saveWorkspace () { + if (isInitialized === false) { return } /* When there is an exception while loading the app, the rootNodes of the workspace get into null value. To avoid saving a corrupt staate we are going to verufy we are not in that situation before saving. */ let workspace = canvas.designSpace.workspace.workspaceNode - for (let i = 0; i < workspace.rootNodes.length; i++) { - let rootNode = workspace.rootNodes[i] - if (rootNode === null) { - canvas.cockpitSpace.setStatus('Could not save the Workspace. The state of the workspace in memory is corrupt, please reload the App.', 150, canvas.cockpitSpace.statusTypes.WARNING) - return - } - } - let savedSessionTimestamp = window.localStorage.getItem('Session Timestamp') if (Number(savedSessionTimestamp) !== sessionTimestamp) { canvas.cockpitSpace.setStatus('Could not save the Workspace. You have more that one instance of the Superlagos User Interface open at the same time. Plese close this instance as it is older than the others.', 150, canvas.cockpitSpace.statusTypes.WARNING)