From 6140872cd904ed031a9508a7644c02b6d91b00a9 Mon Sep 17 00:00:00 2001 From: rr- Date: Tue, 5 Jul 2016 23:14:05 +0200 Subject: [PATCH] client/posts: add implications recursively --- client/js/tags.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/client/js/tags.js b/client/js/tags.js index ae910109..3d62640e 100644 --- a/client/js/tags.js +++ b/client/js/tags.js @@ -90,9 +90,20 @@ function refreshExport() { } function getAllImplications(tagName) { - const actualTag = getTagByName(tagName) || {}; - // TODO: recursive - return actualTag.implications || []; + let implications = []; + let check = [tagName]; + while (check.length) { + let tagName = check.pop(); + const actualTag = getTagByName(tagName) || {}; + for (let implication of actualTag.implications || []) { + if (implications.includes(implication)) { + continue; + } + implications.push(implication); + check.push(implication); + } + } + return Array.from(implications); } function getSuggestions(tagName) {