1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Cache node locales by language

This commit is contained in:
Nick O'Leary 2018-09-28 16:58:06 +01:00
parent ef114e31c2
commit d6211af5bd
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9

View File

@ -24,7 +24,7 @@ var events;
var settings;
var loader;
var nodeConfigCache = null;
var nodeConfigCache = {};
var moduleConfigs = {};
var nodeList = [];
var nodeConstructors = {};
@ -39,7 +39,7 @@ function init(_settings,_loader, _events) {
nodeTypeToId = {};
nodeConstructors = {};
nodeList = [];
nodeConfigCache = null;
nodeConfigCache = {};
}
function load() {
@ -210,7 +210,7 @@ function addModule(module) {
if (module.examples) {
library.addExamplesDir(module.name,module.examples.path);
}
nodeConfigCache = null;
nodeConfigCache = {};
}
@ -233,7 +233,7 @@ function removeNode(id) {
});
config.enabled = false;
config.loaded = false;
nodeConfigCache = null;
nodeConfigCache = {};
return filterNodeInfo(config);
}
@ -389,7 +389,7 @@ function registerNodeConstructor(nodeSet,type,constructor) {
}
function getAllNodeConfigs(lang) {
if (!nodeConfigCache) {
if (!nodeConfigCache[lang]) {
var result = "";
var script = "";
for (var i=0;i<nodeList.length;i++) {
@ -407,9 +407,9 @@ function getAllNodeConfigs(lang) {
// result += UglifyJS.minify(script, {fromString: true}).code;
// result += '</script>';
//}
nodeConfigCache = result;
nodeConfigCache[lang] = result;
}
return nodeConfigCache;
return nodeConfigCache[lang];
}
function getNodeConfig(id,lang) {
@ -448,7 +448,7 @@ function getNodeConstructor(type) {
}
function clear() {
nodeConfigCache = null;
nodeConfigCache = {};
moduleConfigs = {};
nodeList = [];
nodeConstructors = {};
@ -477,7 +477,7 @@ function enableNodeSet(typeOrId) {
config = moduleConfigs[getModule(id)].nodes[getNode(id)];
delete config.err;
config.enabled = true;
nodeConfigCache = null;
nodeConfigCache = {};
settings.enableNodeSettings(config.types);
return saveNodeList().then(function() {
return filterNodeInfo(config);
@ -500,7 +500,7 @@ function disableNodeSet(typeOrId) {
config = moduleConfigs[getModule(id)].nodes[getNode(id)];
// TODO: persist setting
config.enabled = false;
nodeConfigCache = null;
nodeConfigCache = {};
settings.disableNodeSettings(config.types);
return saveNodeList().then(function() {
return filterNodeInfo(config);