From f978c2010497e3e59ac5784424c3102dc687872e Mon Sep 17 00:00:00 2001 From: Ladd Hoffman Date: Sun, 9 Jul 2023 14:25:34 -0500 Subject: [PATCH] Fixup, use string for INCINERATOR_ADDRESS --- forum-network/src/classes/dao/forum.js | 6 ++--- .../src/classes/supporting/vertex.js | 25 ++++++------------- forum-network/src/classes/supporting/wdg.js | 2 +- forum-network/src/util/constants.js | 2 +- 4 files changed, 13 insertions(+), 22 deletions(-) diff --git a/forum-network/src/classes/dao/forum.js b/forum-network/src/classes/dao/forum.js index e65dee2..f06c7b3 100644 --- a/forum-network/src/classes/dao/forum.js +++ b/forum-network/src/classes/dao/forum.js @@ -313,9 +313,6 @@ export class Forum extends ReputationHolder { this.actions.propagate.log(post, author, `(${authorIncrement})`); } - // Increment the value of the post - await post.setValue(newValue); - console.log('propagateValue end', { depth, increment, @@ -325,6 +322,9 @@ export class Forum extends ReputationHolder { refundToInbound, }); + // Increment the value of the post + await post.setValue(newValue); + return refundToInbound; } } diff --git a/forum-network/src/classes/supporting/vertex.js b/forum-network/src/classes/supporting/vertex.js index 160126c..b1ae83b 100644 --- a/forum-network/src/classes/supporting/vertex.js +++ b/forum-network/src/classes/supporting/vertex.js @@ -2,7 +2,7 @@ export class Vertex { constructor(graph, type, id, data, options = {}) { this.graph = graph; this.type = type; - this._id = id; + this.id = id; this.data = data; this.options = options; this.edges = { @@ -16,14 +16,6 @@ export class Vertex { this.installedClickCallback = false; } - set id(newId) { - this._id = newId; - } - - get id() { - return this._id; - } - getEdges(type, away) { return this.edges[away ? 'from' : 'to'].filter( (edge) => edge.type === type, @@ -66,18 +58,17 @@ export class Vertex { name: 'Save', cb: ({ form: { value } }, { initializing }) => { if (initializing) return; + let fullRedraw = false; if (value.id && value.id !== vertex.id) { - // TODO: When an ID changes we really need to wipe out and redraw! - // But we don't yet have a systematic approach for doing that. - // Everything is getting rendered as needed. Lacking abstraction. - // HMM we're not actually that far! Just wipe everything out and draw each vertex and edge :) - // for (const vertex of ) - // for (const edge of [...vertex.edges.to, ...vertex.edges.from]) { - // edge.displayEdge(); - // } + fullRedraw = true; } Object.assign(vertex, value); vertex.displayVertex(); + if (fullRedraw) { + graph.redraw(); + } + }, + }) }, }); diff --git a/forum-network/src/classes/supporting/wdg.js b/forum-network/src/classes/supporting/wdg.js index 41f2ad6..45b333e 100644 --- a/forum-network/src/classes/supporting/wdg.js +++ b/forum-network/src/classes/supporting/wdg.js @@ -83,7 +83,7 @@ export class WeightedDirectedGraph { } } - // Rerender + // Ensure rerender this.flowchart?.render(); } diff --git a/forum-network/src/util/constants.js b/forum-network/src/util/constants.js index 65b28c9..fbfdb79 100644 --- a/forum-network/src/util/constants.js +++ b/forum-network/src/util/constants.js @@ -1,6 +1,6 @@ export const EPSILON = 2.23e-16; -export const INCINERATOR_ADDRESS = 0; +export const INCINERATOR_ADDRESS = '0'; export const EdgeTypes = { CITATION: 'citation',