Skip to content

Commit

Permalink
Merge 7c4ec57 into e4f553d
Browse files Browse the repository at this point in the history
  • Loading branch information
BarbourSmith committed Jun 10, 2021
2 parents e4f553d + 7c4ec57 commit 6a32829
Showing 1 changed file with 33 additions and 18 deletions.
51 changes: 33 additions & 18 deletions src/js/molecules/githubmolecule.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,32 +66,47 @@ export default class GitHubMolecule extends Molecule {
const json = await GlobalVariables.gitHub.getProjectByID(id, this.topLevel)

const projectData = await GlobalVariables.gitHub.getProjectDataByID(id)
if(projectData){
const values = {key: "fromJSON", writePath: this.path, json: projectData}
window.ask(values)
}

//Store values that we want to overwrite in the loaded version
var valuesToOverwriteInLoadedVersion
if(this.topLevel){
valuesToOverwriteInLoadedVersion = {atomType: this.atomType, topLevel: this.topLevel}
if(projectData && json.ioValues.length == 0){ //If this github molecule has no inputs
const projectData = await GlobalVariables.gitHub.getProjectDataByID(id)
if(projectData){
this.name = json.name
const values = {key: "fromJSON", writePath: this.path, json: projectData}
window.ask(values)
this.nodesOnTheScreen.forEach( atom => {
if(atom.atomType == "Output"){
atom.path = this.path
atom.inputs[0].setValue(this.path)
}
})
this.propogate()
}
let aPromise = new Promise((resolve) => {
resolve()
})
return aPromise
}
else{
//If there are stored io values to recover
if(this.ioValues != undefined){
valuesToOverwriteInLoadedVersion = {uniqueID: this.uniqueID, x: this.x, y: this.y, atomType: this.atomType, topLevel: this.topLevel, ioValues: this.ioValues}
//Store values that we want to overwrite in the loaded version
var valuesToOverwriteInLoadedVersion
if(this.topLevel){
valuesToOverwriteInLoadedVersion = {atomType: this.atomType, topLevel: this.topLevel}
}
else{
valuesToOverwriteInLoadedVersion = {uniqueID: this.uniqueID, x: this.x, y: this.y, atomType: this.atomType, topLevel: this.topLevel}
//If there are stored io values to recover
if(this.ioValues != undefined){
valuesToOverwriteInLoadedVersion = {uniqueID: this.uniqueID, x: this.x, y: this.y, atomType: this.atomType, topLevel: this.topLevel, ioValues: this.ioValues}
}
else{
valuesToOverwriteInLoadedVersion = {uniqueID: this.uniqueID, x: this.x, y: this.y, atomType: this.atomType, topLevel: this.topLevel}
}
}
}
const promsie = this.deserialize(json, valuesToOverwriteInLoadedVersion, true).then( () => {
if(!projectData){ //If we haven't loaded the project directly then recompute the ouput
const promsie = this.deserialize(json, valuesToOverwriteInLoadedVersion, true).then( () => {
this.setValues(valuesToOverwriteInLoadedVersion)
this.loadTree()
}
})
return promsie
})
return promsie
}
}

/**
Expand Down

0 comments on commit 6a32829

Please sign in to comment.