mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
refactor: call topic events init from within file itself
This commit is contained in:
@@ -42,19 +42,19 @@ Events._types = {
|
|||||||
text: '[[topic:restored-by]]',
|
text: '[[topic:restored-by]]',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
Events._ready = false;
|
|
||||||
|
|
||||||
Events.init = async () => {
|
async function init() {
|
||||||
if (!Events._ready) {
|
if (!plugins.hooks) {
|
||||||
// Allow plugins to define additional topic event types
|
return setImmediate(init);
|
||||||
const { types } = await plugins.hooks.fire('filter:topicEvents.init', { types: Events._types });
|
|
||||||
Events._types = types;
|
|
||||||
Events._ready = true;
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
// Allow plugins to define additional topic event types
|
||||||
|
const { types } = await plugins.hooks.fire('filter:topicEvents.init', { types: Events._types });
|
||||||
|
Events._types = types;
|
||||||
|
}
|
||||||
|
init();
|
||||||
|
|
||||||
Events.get = async (tid) => {
|
Events.get = async (tid) => {
|
||||||
await Events.init();
|
|
||||||
const topics = require('.');
|
const topics = require('.');
|
||||||
|
|
||||||
if (!await topics.exists(tid)) {
|
if (!await topics.exists(tid)) {
|
||||||
@@ -104,7 +104,6 @@ async function modifyEvent({ eventIds, timestamps, events }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Events.log = async (tid, payload) => {
|
Events.log = async (tid, payload) => {
|
||||||
await Events.init();
|
|
||||||
const topics = require('.');
|
const topics = require('.');
|
||||||
const { type } = payload;
|
const { type } = payload;
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
|
|||||||
Reference in New Issue
Block a user