beforeMessageBodyTransformed plugin hooks (and others) are not respecting async/await
OCDolan opened this issue · 1 comments
Describe the bug
beforeMessageBodyTransformed
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 behavior
beforeMessageBodyTransformed
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.
Thanks!
FYI i've found it in 5 places - chatBoxInitialized, messageInitialized, chatRoomInitialized, rosterContactInitialized, afterMessageBodyTransformed