summaryrefslogtreecommitdiff
path: root/src/static
diff options
context:
space:
mode:
authorMarcel Klehr <mklehr@gmx.net>2013-03-25 12:45:23 +0100
committerMarcel Klehr <mklehr@gmx.net>2013-03-25 12:45:23 +0100
commit0070eab4164ef473c706fe7f1f5c8064e7c819b9 (patch)
tree37117c8c36734ed74f51570920921bb8b8036694 /src/static
parentef7fb5c7f0e233268530eb8cd6eb02224751dae5 (diff)
downloadetherpad-lite-0070eab4164ef473c706fe7f1f5c8064e7c819b9.zip
Fix caching of npm search results and only make one registry request on /admin/plugins
fixes #1488
Diffstat (limited to 'src/static')
-rw-r--r--src/static/js/admin/plugins.js6
-rw-r--r--src/static/js/pluginfw/installer.js6
2 files changed, 8 insertions, 4 deletions
diff --git a/src/static/js/admin/plugins.js b/src/static/js/admin/plugins.js
index a973875c..d7f94d2c 100644
--- a/src/static/js/admin/plugins.js
+++ b/src/static/js/admin/plugins.js
@@ -163,8 +163,10 @@ $(document).ready(function () {
}
updateHandlers();
- socket.emit('checkUpdates');
- tasks++;
+ setTimeout(function() {
+ socket.emit('checkUpdates');
+ tasks++;
+ }, 5000)
});
socket.on('updatable', function(data) {
diff --git a/src/static/js/pluginfw/installer.js b/src/static/js/pluginfw/installer.js
index 15d87940..14a3b7be 100644
--- a/src/static/js/pluginfw/installer.js
+++ b/src/static/js/pluginfw/installer.js
@@ -71,12 +71,13 @@ exports.install = function(plugin_name, cb) {
};
exports.searchCache = null;
+var cacheTimestamp = 0;
-exports.search = function(query, cache, cb) {
+exports.search = function(query, maxCacheAge, cb) {
withNpm(
function (cb) {
var getData = function (cb) {
- if (cache && exports.searchCache) {
+ if (maxCacheAge && exports.searchCache && Math.round(+new Date/1000)-cacheTimestamp < maxCacheAge) {
cb(null, exports.searchCache);
} else {
registry.get(
@@ -84,6 +85,7 @@ exports.search = function(query, cache, cb) {
function (er, data) {
if (er) return cb(er);
exports.searchCache = data;
+ cacheTimestamp = Math.round(+new Date/1000)
cb(er, data);
}
);