From adf56057ff4f56d8a3b7c1e82422a62a0b047d21 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Sun, 7 Jun 2020 19:34:54 +0200 Subject: tidy lines --- frontend/views/graph/components/graph.editor.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'frontend/views/graph/components/graph.editor.js') diff --git a/frontend/views/graph/components/graph.editor.js b/frontend/views/graph/components/graph.editor.js index a6d46d4..c1b3432 100644 --- a/frontend/views/graph/components/graph.editor.js +++ b/frontend/views/graph/components/graph.editor.js @@ -220,13 +220,17 @@ class GraphCanvas extends Component { const targetCoord = coordsLookup[tile.page_id] let xOffset = 16 let yOffset = 16 - // console.log(tile.page_id, tile.target_page_id, sourceCoord.backlinks, targetCoord.backlinks) - if (targetCoord.backlinks.has(tile.target_page_id)) { - xOffset += 10 - ctx.strokeStyle = "#88ffff" - } else { + // skip duplicate links + if (sourceCoord.backlinks.has(tile.page_id)) { + return + } + // if this is the first time encountering this link... + if (!targetCoord.backlinks.has(tile.target_page_id)) { sourceCoord.backlinks.add(tile.page_id) ctx.strokeStyle = "#ff88ff" + } else { // otherwise this is a two-way link + xOffset += 10 + ctx.strokeStyle = "#88ffff" } ctx.beginPath() const x1 = targetCoord.x * width + xOffset -- cgit v1.2.3-70-g09d2