From 5eb130b02ab9c2b7caf942f91e9f86c3d1d223bf Mon Sep 17 00:00:00 2001 From: rr- Date: Fri, 16 Sep 2016 21:34:38 +0200 Subject: [PATCH] client/tags: blind fix for tags.json race I don't want to make the UI wait for tags.json to load, I'd rather not color categories on some pages instead. --- client/js/controls/tag_auto_complete_control.js | 3 +-- client/js/tags.js | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/client/js/controls/tag_auto_complete_control.js b/client/js/controls/tag_auto_complete_control.js index b43cd9a4..2fffcf9e 100644 --- a/client/js/controls/tag_auto_complete_control.js +++ b/client/js/controls/tag_auto_complete_control.js @@ -6,7 +6,6 @@ const AutoCompleteControl = require('./auto_complete_control.js'); class TagAutoCompleteControl extends AutoCompleteControl { constructor(input, options) { - const allTags = tags.getNameToTagMap(); const caseSensitive = false; const minLengthForPartialSearch = 3; @@ -22,7 +21,7 @@ class TagAutoCompleteControl extends AutoCompleteControl { (a, b) => a.startsWith(b) : (a, b) => a.includes(b); text = transform(text); - return Array.from(allTags.entries()) + return Array.from(tags.getNameToTagMap().entries()) .filter(kv => match(transform(kv[0]), text)) .sort((kv1, kv2) => { return kv2[1].usages - kv1[1].usages; diff --git a/client/js/tags.js b/client/js/tags.js index e732400f..18b9b625 100644 --- a/client/js/tags.js +++ b/client/js/tags.js @@ -3,8 +3,8 @@ const misc = require('./util/misc.js'); const request = require('superagent'); -let _tags = null; -let _categories = null; +let _tags = new Map(); +let _categories = new Map(); let _stylesheet = null; function getTagByName(name) {