mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
fixes in event propagation
This commit is contained in:
parent
1ad406ced5
commit
89a4165c77
@ -51,7 +51,7 @@ export default class Component {
|
||||
// don't create promises if not needed (optimization)
|
||||
return callMethodPromise && childrenPromise
|
||||
? Promise.all([callMethodPromise, childrenPromise])
|
||||
: null;
|
||||
: (callMethodPromise || childrenPromise);
|
||||
}
|
||||
|
||||
/** @returns {Promise} */
|
||||
@ -64,11 +64,15 @@ export default class Component {
|
||||
const promises = [];
|
||||
|
||||
for (const child of this.children) {
|
||||
promises.push(child.handleEvent(name, data));
|
||||
const ret = child.handleEvent(name, data);
|
||||
|
||||
if (ret) {
|
||||
promises.push(ret);
|
||||
}
|
||||
}
|
||||
|
||||
// don't create promises if not needed (optimization)
|
||||
return promises.find(p => p) ? Promise.all(promises) : null;
|
||||
return promises.length > 0 ? Promise.all(promises) : null;
|
||||
}
|
||||
|
||||
/** @returns {Promise} */
|
||||
@ -83,9 +87,9 @@ export default class Component {
|
||||
}
|
||||
}
|
||||
|
||||
async callMethod(fun, data) {
|
||||
callMethod(fun, data) {
|
||||
if (typeof fun !== 'function') {
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
const startTime = Date.now();
|
||||
@ -98,14 +102,10 @@ export default class Component {
|
||||
console.log(`Call to ${fun.name} in ${this.componentId} took ${took}ms`);
|
||||
}
|
||||
|
||||
if (glob.isDev) {
|
||||
await utils.timeLimit(promise, 20000, `Time limit failed on ${this.constructor.name} with ${fun.name}`);
|
||||
}
|
||||
else {
|
||||
// cheaper and in non-dev the extra reporting is lost anyway through reload
|
||||
await promise;
|
||||
if (glob.isDev && promise) {
|
||||
return utils.timeLimit(promise, 20000, `Time limit failed on ${this.constructor.name} with ${fun.name}`);
|
||||
}
|
||||
|
||||
return true;
|
||||
return promise;
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ export default class NoteContextAwareWidget extends BasicWidget {
|
||||
}
|
||||
|
||||
get notePath() {
|
||||
return this.noteContext.notePath && this.noteContext;
|
||||
return this.noteContext?.notePath;
|
||||
}
|
||||
|
||||
get hoistedNoteId() {
|
||||
@ -64,7 +64,7 @@ export default class NoteContextAwareWidget extends BasicWidget {
|
||||
async refreshWithNote(note) {}
|
||||
|
||||
async noteSwitchedEvent({noteContext, notePath}) {
|
||||
// if notePath does not match then the noteContext has been switched to another note in the mean time
|
||||
// if notePath does not match then the noteContext has been switched to another note in the meantime
|
||||
if (noteContext.notePath === notePath) {
|
||||
await this.noteSwitched();
|
||||
}
|
||||
@ -88,7 +88,7 @@ export default class NoteContextAwareWidget extends BasicWidget {
|
||||
async noteSwitchedAndActivatedEvent({noteContext, notePath}) {
|
||||
this.noteContext = noteContext;
|
||||
|
||||
// if notePath does not match then the noteContext has been switched to another note in the mean time
|
||||
// if notePath does not match then the noteContext has been switched to another note in the meantime
|
||||
if (this.notePath === notePath) {
|
||||
await this.refresh();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user