Modify Ember model class using Theme Component

Hi All,

I want to modify below mention method of topic model class javascripts/discourse/app/models/topic.js

    @discourseComputed("excerpt")
      excerptTruncated(excerpt) {
        return excerpt && excerpt.substr(excerpt.length - 8, 8) === "…";
      }

Tried using below code but its not working:

<script type="text/discourse-plugin" version="0.8">

const topicClass = api.container.factoryFor('model:topic');
const discourseComputed = require("discourse-common/utils/decorators").default;

topicClass.class.reopenClass({
  @discourseComputed("excerpt")
  excerptTruncated(excerpt) {
	return excerpt && excerpt.substr(topic_excerpt.length - 8, 8) === "&hellip;";
  }
});
</script>
1 Like

You can directly do

api.modifyClass('model:topic', {
});
2 Likes