こんにちは、私も同じ問題に直面しましたが、トピックを再度取得して必要なデータを入手することで解決できました。これは topic-list-item.js コンポーネント内で Ember.PromiseProxyMixin を使用して実装しました。使い方はこちらをご覧ください: Use Ember.PromiseProxyMixin in a theme
コードは以下のようになります:
// リクエスト数を減らすために、カスタムの memoize 関数を使用しています
const getTopic = memoize(id => ajax(`/t/${id}.json`).then(data => data));
// ...
// コンポーネント内
@discourseComputed("topic")
topicPromise(topic) {
return getTopic(topic.id);
},
@discourseComputed("topicPromise")
topicProxy() {
const promise = this.get("topicPromise");
return promise && PromiseObject.create({ promise });
},
postStream: reads("topicProxy.content.post_stream"),
@discourseComputed("postStream")
excerpt(postStream) {
if (!this.get("postStream")) return false;
return `${stripHtml(postStream.posts[0].cooked).slice(0, 150)}...`;
},
stripHtml は、最初の投稿から HTML を除去するためのカスタム関数です。
topic-list-item.hbs には以下のように記述します:
{{#if topicProxy.isFulfilled}}
<div class="excerpt">
{{#if excerpt}}
{{html-safe excerpt}}
{{/if}}
</div>
{{/if}}