Describe the bugbeforeMessageBodyTransformed plugin hooks (and others) are not respecting async/await
To Reproduce
Steps to reproduce the behavior:
_converse.api.listen.on('beforeMessageBodyTransformed', async (text, view) => {
console.log("beforeMessageBodyTransformed");
await something(text); // This await doesn't work, because beforeMessageBodyTransformed returns immedietly!
});
Expected behaviorbeforeMessageBodyTransformed should wait untill await something(text) finishes before starting afterMessageBodyTransformed
Screenshots
None
Environment (please complete the following information):
Desktop or Mobile? Affects all
Browser [e.g. Chrome, Firefox] Affects all
Converse.js version [e.g. 4.2.0] Latest
Additional context
None
!!! CAUSE + HOW TO FIX !!!
The cause of the bug is a capitalization error in rich-text.js.
await api.trigger('beforeMessageBodyTransformed', this, { 'Synchronous': true }); should be await api.trigger('beforeMessageBodyTransformed', this, { 'synchronous': true });synchronous not Synchronous!
I think this affects several plugin hooks, not just this one i've found, it might be worth doing a regex to find all instances of this bug.
Describe the bug
beforeMessageBodyTransformed
plugin hooks (and others) are not respecting async/awaitTo Reproduce Steps to reproduce the behavior: _converse.api.listen.on('beforeMessageBodyTransformed', async (text, view) => { console.log("beforeMessageBodyTransformed"); await something(text); // This await doesn't work, because beforeMessageBodyTransformed returns immedietly! });
Expected behavior
beforeMessageBodyTransformed
should wait untillawait something(text)
finishes before startingafterMessageBodyTransformed
Screenshots None
Environment (please complete the following information):
Additional context None
!!! CAUSE + HOW TO FIX !!! The cause of the bug is a capitalization error in rich-text.js.
await api.trigger('beforeMessageBodyTransformed', this, { 'Synchronous': true });
should beawait api.trigger('beforeMessageBodyTransformed', this, { 'synchronous': true });
synchronous
notSynchronous
!I think this affects several plugin hooks, not just this one i've found, it might be worth doing a regex to find all instances of this bug.
Thanks!