Skip to content

Commit

Permalink
remove already added topics from dropdown list
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Gnehr <[email protected]>
  • Loading branch information
Cherrg committed Jun 28, 2019
1 parent a687e94 commit d68d410
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion public/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2877,15 +2877,24 @@ function initTopicbar() {

let query = escapeHtml(this.urlData.query.trim());
let found_query = false;
let current_topics = [];
topicDropdown.find('div.label.visible.topic,a.label.visible').each(function(_,e){ current_topics.push(e.dataset.value); });

if (res.topics) {
formattedResponse.success = true;
let found = false;
for (let i=0;i < res.topics.length;i++) {
// skip currently added tags
if (current_topics.indexOf(res.topics[i].Name) != -1){
continue;
}

if (res.topics[i].Name.toLowerCase() === query.toLowerCase()){
found_query = true;
}
formattedResponse.results.push({"description": res.topics[i].Name, "data-value": res.topics[i].Name});
found = true;
}
formattedResponse.success = found;
}

if (query.length > 0 && !found_query){
Expand Down

0 comments on commit d68d410

Please sign in to comment.