this.afterRefresh() is not a function

AI-generated summary

After upgrading to Discourse 2.4.0 beta, piratdavid encountered an error with uploading due to “this.afterRefresh() is not a function” in composer-editor.js. joffreyjaffeux suggested checking in safe-mode, but piratdavid found that the issue was related to the deprecation of sendAction and the different usage of afterRefresh in composer-editor.js. joffreyjaffeux confirmed that sendAction was deprecated and actions are now simple closures. To fix the issue, joffreyjaffeux advised calling the action as a function. piratdavid discovered that defining afterRefresh in the composer-editor tag parameters in the template file was required.

Hi! Long time since I looked over our plugins. After upgrading to 2.4.0 beta I encounter errors with uploading. The composer-editor.js class fails with “this.afterRefresh() is not a function”. To me it looks like this might be an old action in the ember Component class but I might be wrong. Finding nothing about it. Could this be some legacy or am I using deprecated code? Thanx

Do you have this issue in safe-mode ?

It’s with my own plugins installed so running in safe mode doesn’t help me find the issue. This particular plugin uses the composer-editor component in a template file.

I checked out v2.3.6 and searched for afterRefresh. It seems the composer-editor.js is using it differently. this.afterRefresh($preview); instead of this.sendAction(‘afterRefresh’, $preview); This at least seems to be the problem.

It was unclear from your post if you were thinking it was coming from plugins or core.

Can’t help much without having access to code. But what you said is right sendAction is deprecated and shouldn’t be used anymore, actions are now simple closures.

Allright, so just calling the action as a function is the correct way now? Then I guess I’ll have to look over my code. I thought maybe it was a bug.

Yes calling it as a function should be the expected usage.

I hadn’t defined afterRefresh in the composer-editor tag parameters in the template file. I guess that is required.