diff --git a/hunks/view.js b/hunks/view.js index b781c331dd0d7b0292b0cbee185c15cfb570d57d..0803d3de95e3b1c3421e40e0c9490d714d581f29 100644 --- a/hunks/view.js +++ b/hunks/view.js @@ -352,24 +352,36 @@ function View() { return def } // FIN NEWDEF - let updateDef = (def) => { - throw new Error('you need to rewrite this') + + let updateDef = (spec) => { + console.log('UPDATE') // with an update, we maintain link topology // with a replace, we wipe link topology, // and manager is responsible for updating us with new links - let cdef = defs[def.ind] + let def = defs[spec.ind] // check name, - if (def.name !== cdef.name) { - cdef.updateName(def.name) + if (def.name !== spec.name) { + def.name = spec.name + setDefUpdate(def.ind) } // check states, for (let st in def.states) { - if (def.states[st].value !== cdef.states[st].value) { - cdef.states[st].value = def.states[st].value + if (def.states[st].value !== spec.states[st].value) { + def.states[st].value = spec.states[st].value // not too sure about this, - setDefUpdate(cdef.ind) + setDefUpdate(def.ind) } } + // get any startup conn attached to existing handle, and watch inputs / outputs + for(let ip in def.inputs){ + if(spec.inputs[ip].type !== def.inputs[ip].type) throw new Error('bad time no good') // shouldn't be the case for updates, + def.inputs[ip].name = spec.inputs[ip].name + } + for(let op in def.outputs){ + if(spec.outputs[op].type !== def.outputs[op].type) throw new Error('also very bad') // same, + def.outputs[op].name = spec.outputs[op].name + if(spec.outputs[op].startupConn) def.outputs[op].startupConn = spec.outputs[op].startupConn + } // check link link try { reconcileStartupConn(def) @@ -476,13 +488,15 @@ function View() { for (let op of def.outputs) { if (!op.startupConn) continue for (let cn of op.startupConn) { + // does it already exist? + if(op.conn.includes(defs[cn[0]].inputs[cn[1]])) continue putLink(def.ind, op.ind, cn[0], cn[1]) } delete op.startupConn } } - let putLink = (outInd, outputInd, inInd, inputInd, startup) => { + let putLink = (outInd, outputInd, inInd, inputInd) => { try { let outputDef = defs[outInd].outputs[outputInd] let inputDef = defs[inInd].inputs[inputInd] @@ -728,7 +742,6 @@ function View() { // wipe ya docs, and ask yonder manager for a complete description // setting ahn JS array's length to zero effectively erases it, unless // there are other references to them someplace ... then GC will keepalive - defs.length = 0 // here we can set flag for complete redraw, as we've just tabula'd the table, setCompleteRedraw() // hello first, @@ -1151,6 +1164,7 @@ function View() { let spec = deserializeDef(msg, inc + 1, false) // so first we check for an existing hunk, let nd + console.log('HERE', defs[spec.ind]) if (defs[spec.ind] === undefined) { nd = newDef(spec) //console.log('the nd', nd) @@ -1170,7 +1184,7 @@ function View() { let repSpec = deserializeDef(msg, inc + 1, false) if (defs[repSpec.ind] === undefined) { console.error('received hunk replace for non existent hunk') - console.error('ere is the spec:', repSpec) + console.error('here is the spec:', repSpec) } else { replaceDef(repSpec) if (cbd) cbd.callback(nd) diff --git a/view/blocks.js b/view/blocks.js index 09dedc62cfd0c9ff0d0e84f3f72207783dde4d15..8b20be89255fa5e3d7c10acf4cda383d28a57151 100644 --- a/view/blocks.js +++ b/view/blocks.js @@ -306,7 +306,7 @@ let rebuildDef = (def, position) => { def.context.routelink(def).then((view) => { console.log('route ok') // oddly, - def.contains = view + def.contains = view // we *do* want to walk these, so we want a handle to // the view element - not just its def ... view.refresh().then(() => { @@ -321,7 +321,8 @@ let rebuildDef = (def, position) => { }) } let close = (evt) => { - console.error('not yet') + wipeContext(def.contains) + $(def.contains.plane).remove() // . then-> $(squid).html('<i class="em em-squid"></i> expand link') $(squid).one('click', open)