mirror of
https://github.com/zadam/trilium.git
synced 2024-09-21 16:16:04 +08:00
all events are now synchronous
This commit is contained in:
parent
9fb0599c45
commit
c78ddb70cb
|
@ -65,7 +65,7 @@ async function loginToProtectedSession(req) {
|
|||
// this is set here so that event handlers have access to the protected session
|
||||
cls.namespace.set('protectedSessionId', protectedSessionId);
|
||||
|
||||
eventService.emit(eventService.ENTER_PROTECTED_SESSION);
|
||||
await eventService.emit(eventService.ENTER_PROTECTED_SESSION);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
|
|
|
@ -9,18 +9,7 @@ function subscribe(eventType, listener) {
|
|||
eventListeners[eventType].push(listener);
|
||||
}
|
||||
|
||||
function emit(eventType, data) {
|
||||
const listeners = eventListeners[eventType];
|
||||
|
||||
if (listeners) {
|
||||
for (const listener of listeners) {
|
||||
// not awaiting for async processing
|
||||
listener(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function syncEmit(eventType, data) {
|
||||
async function emit(eventType, data) {
|
||||
const listeners = eventListeners[eventType];
|
||||
|
||||
if (listeners) {
|
||||
|
@ -33,7 +22,6 @@ async function syncEmit(eventType, data) {
|
|||
module.exports = {
|
||||
subscribe,
|
||||
emit,
|
||||
syncEmit,
|
||||
// event types:
|
||||
NOTE_TITLE_CHANGED,
|
||||
ENTER_PROTECTED_SESSION,
|
||||
|
|
|
@ -53,7 +53,7 @@ async function addEntitySync(entityName, entityId, sourceId) {
|
|||
sourceId: sourceId || cls.getSourceId() || sourceIdService.getCurrentSourceId()
|
||||
});
|
||||
|
||||
await eventService.syncEmit(eventService.ENTITY_CHANGED, {
|
||||
await eventService.emit(eventService.ENTITY_CHANGED, {
|
||||
entityName,
|
||||
entityId
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue