How to correctly listen on post-stream update

The decorateCookedElement api will be triggered once for each rendered post. The callback will be passed the DOM element containing the post content. The idea is that you only modify the element you’ve been passed, and not anything else on the page.

But since you want to make modifications to the metadata around the post content, decorateCookedElement probably isn’t the right option.

Then the best thing is probably to look at how the addPosterIcon API is implemented:

Under the covers it is a call to the api.decorateWidget function. You could make that call yourself, and then make it render raw HTML. For more information about the decorateWidget API, you can check https://meta.discourse.org/t/developer-s-guide-to-discourse-themes/93648#heading--4-c-6

1 Like