Skip to content

Commit

Permalink
fixed a long standing bug/issue causing leaf nodes to turn into topic…
Browse files Browse the repository at this point in the history
…s. When saving from a TG was checking for tg-name == node.topicName, but not validating that the node was itself the topic node.
  • Loading branch information
tconfrey committed Dec 2, 2024
1 parent 6f8f68f commit 40ff860
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions versions/1.1/app/BTAppNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ class BTAppNode extends BTNode {
// find topic from tab group
return AllNodes.find(node => node && node.isTopic() && node.tabGroupId == groupId);
}

static findOrCreateFromTopicDN(topicDN) {
// Walk down tree of topics from top, finding or creating nodes & tt display nodes
let components = topicDN.match(/.*?:/g);
Expand All @@ -976,29 +976,29 @@ class BTAppNode extends BTNode {
const topTopic = (components && components.length) ? components[0] : topic;

// Find or create top node
let topNode = AllNodes.find(node => node && node.topicName() == topTopic);
let topNode = AllNodes.find(node => node && (node.topicName() == topTopic) && (node.isTopic()));
if (!topNode) {
topNode = new BTAppNode(topTopic, null, "", 1);
topNode.createDisplayNode();
}

if (!components) return topNode;

// Remove, now handled first elt, Walk down rest creating as needed
let currentNode = topNode;
components.shift();
components.forEach((t) => {
let node = currentNode;
currentNode = currentNode.findChild(t);
currentNode = currentNode.findTopicChild(t);
if (!currentNode) {
currentNode = new BTAppNode(t, node.id, "", node.level + 1);
currentNode.createDisplayNode();
}
});

// finally find or create the leaf node
if (currentNode.findChild(topic))
return currentNode.findChild(topic);
if (currentNode.findTopicChild(topic))
return currentNode.findTopicChild(topic);
let newLeaf = new BTAppNode(topic, currentNode.id, "", currentNode.level + 1);
newLeaf.createDisplayNode();
topNode.redisplay(); // since new nodes created
Expand Down
6 changes: 3 additions & 3 deletions versions/1.1/app/BTNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ class BTNode {
this._childIds.splice(index, 1);
}

findChild(childTopic) {
findTopicChild(childTopic) {
// does this topic node have this sub topic
const childId = this.childIds.find(id => AllNodes[id].topicName() == childTopic);
const childId = this.childIds.find(id => (AllNodes[id].isTopic () && (AllNodes[id].topicName() == childTopic)));
return childId ? AllNodes[childId] : null;
}

getDescendantIds() {
// return a list of all the descendant node ids
let descendants = [];
Expand Down

0 comments on commit 40ff860

Please sign in to comment.