diff --git a/hunks/view.js b/hunks/view.js index 3ede783dd14c5e6dca34496b95efe3d20dd31ea3..69573e347154d612da706f5640e7eaf018cb2819 100644 --- a/hunks/view.js +++ b/hunks/view.js @@ -676,10 +676,10 @@ function View() { this.requestAddLinkLikeACaveman = (outInd, outputInd, inInd, inputInd) => { return new Promise((resolve, reject) => { let msg = [MK.REQADDLINK] - MSGS.writeTo(msg, outInd, 'uint16') - MSGS.writeTo(msg, outputInd, 'uint8') - MSGS.writeTo(msg, inInd, 'uint16') - MSGS.writeTo(msg, inputInd, 'uint8') + MSGS.writeTo(msg, parseInt(outInd), 'uint16') + MSGS.writeTo(msg, parseInt(outputInd), 'uint8') + MSGS.writeTo(msg, parseInt(inInd), 'uint16') + MSGS.writeTo(msg, parseInt(inputInd), 'uint8') promiseThis(msg, (link) => { resolve(link) }, (errmsg) => { @@ -945,9 +945,42 @@ function View() { }) } - let mergeLinkList = (patch) => { - return new Promise(async (resolve, reject) => { - resolve() + let mergeLinkList = (patch, debug) => { + return new Promise((resolve, reject) => { + let nh = patch.hunks.length + let recursor = async (n) => { + // we want to walk the list of outputs in the patch, and reconn. + for(let op in patch.hunks[n].outputs){ + if(!defs[n].outputs[op]) break + for(let cn of patch.hunks[n].outputs[op].conn){ + if(debug) console.log('mergeLinkList would like to conn', n, op, 'to', cn) + // now! we would like to see about whether / not this link already exist. + // it's possible to double up wires, so let's try not to ... + let existenceProof = defs[n].outputs[op].conn.find((cand) => { + // recall: the candidate is ahn input, in this outputs' list of connections + return ((cand.ind == cn[1]) && (cand.parent.ind == cn[0])) + }) + if(existenceProof){ + if(debug) console.log('link exists, continueing') + continue + } + // here is case to put error handling in the ll, at addlink, + // then just ignore the ones we miss ... + try { + this.requestAddLinkLikeACaveman(n, op, cn[0], cn[1]) + } catch (err) { + console.error('passing by this erroneous link-addition during link-list merging') + console.error(err) + } + } + }// end for-each-output + if((n ++) < (nh - 1)){ + recursor(n++) + } else { + resolve() + } + } // end recursor, + recursor(0) }) } diff --git a/view/contextmenu.js b/view/contextmenu.js index 03bc0e10bf72560e80d5fa08ab0d84bcd0f36a95..17f5f41b938cb02a732e58f0027ab48bac04cefd 100644 --- a/view/contextmenu.js +++ b/view/contextmenu.js @@ -425,7 +425,8 @@ function planeMenu(evt, context) { $(ce.target).closest('li').append(' > requested ... ') gg.getJson(`save/systems/${item}.json`).then((obj) => { // apparently, it's actually promises all the way down - context.reinstate(obj).then((yikes) => { + // 2nd arg is debug state + context.reinstate(obj, true).then((yikes) => { // trigger re-render? do we get heavy handed here and shut it down // ... i.e. don't render anything until it's thru ? console.warn('reinstate complete ? redraw ?')