mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-09 23:45:45 +01:00
don't bother firing hooks received by js unless a listener exists
This commit is contained in:
@@ -5,7 +5,7 @@ define(['uploader'], function(uploader) {
|
|||||||
Settings.prepare();
|
Settings.prepare();
|
||||||
};
|
};
|
||||||
|
|
||||||
Settings.prepare = function() {
|
Settings.prepare = function(callback) {
|
||||||
// Come back in 125ms if the config isn't ready yet
|
// Come back in 125ms if the config isn't ready yet
|
||||||
if (!app.config) {
|
if (!app.config) {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
@@ -117,6 +117,10 @@ define(['uploader'], function(uploader) {
|
|||||||
$(this).tab('show');
|
$(this).tab('show');
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (typeof callback === 'function') {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Settings.remove = function(key) {
|
Settings.remove = function(key) {
|
||||||
|
|||||||
@@ -20,8 +20,15 @@ var nconf = require('nconf'),
|
|||||||
|
|
||||||
app.put('/plugins/fireHook', function(req, res) {
|
app.put('/plugins/fireHook', function(req, res) {
|
||||||
// PUT = action
|
// PUT = action
|
||||||
plugins.fireHook('action:' + req.body.hook, req.body.args);
|
var hook = 'action:' + req.body.hook;
|
||||||
res.send(200);
|
if (plugins.hasListeners(hook)) {
|
||||||
|
// Hook executes
|
||||||
|
plugins.fireHook(hook, req.body.args);
|
||||||
|
res.send(200);
|
||||||
|
} else {
|
||||||
|
// No listeners for this hook
|
||||||
|
res.send(404);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Static Assets
|
// Static Assets
|
||||||
|
|||||||
Reference in New Issue
Block a user