Skip to content
This repository has been archived by the owner on Aug 22, 2023. It is now read-only.

Commit

Permalink
fix: fixed bugs with topic parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Feb 6, 2018
1 parent 4616a5c commit fb639fd
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@ export class Plugin implements IPlugin {
let topics = [...this._topics]
for (let plugin of this.plugins) {
for (let topic of plugin.topics) {
let existing = topics.find(t => t.name === t.name)
let existing = topics.find(t => t.name === topic.name)
if (existing) {
existing.description = topic.description || existing.description
existing.hidden = topic.hidden === undefined ? existing.hidden : topic.hidden
existing.hidden = existing.hidden || topic.hidden
} else topics.push(topic)
}
topics = [...topics, ...plugin.topics]
Expand Down Expand Up @@ -333,9 +333,13 @@ export class Plugin implements IPlugin {

protected addMissingTopics() {
for (let c of this.commands.filter(c => !c.hidden)) {
let name = c.id.split(':').slice(0, -1).join(':')
if (name && !this._topics.find(t => t.name === name)) {
this._topics.push({name})
let parts = c.id.split(':')
while (parts.length) {
let name = parts.join(':')
if (name && !this._topics.find(t => t.name === name)) {
this._topics.push({name})
}
parts.pop()
}
}
}
Expand Down

0 comments on commit fb639fd

Please sign in to comment.