diff --git a/app/assets/javascripts/discourse/components/topic-list-item.js.es6 b/app/assets/javascripts/discourse/components/topic-list-item.js.es6 index 2909dce548..7bc2d64603 100644 --- a/app/assets/javascripts/discourse/components/topic-list-item.js.es6 +++ b/app/assets/javascripts/discourse/components/topic-list-item.js.es6 @@ -1,9 +1,8 @@ -import discourseComputed from "discourse-common/utils/decorators"; +import discourseComputed, { observes } from "discourse-common/utils/decorators"; import { alias } from "@ember/object/computed"; import Component from "@ember/component"; import { schedule } from "@ember/runloop"; import DiscourseURL from "discourse/lib/url"; -import { bufferedRender } from "discourse-common/lib/buffered-render"; import { findRawTemplate } from "discourse/lib/raw-templates"; import { wantsNewWindow } from "discourse/lib/intercept-click"; import { on } from "@ember/object/evented"; @@ -33,12 +32,25 @@ export function navigateToTopic(topic, href) { return false; } -export const ListItemDefaults = { +export default Component.extend({ tagName: "tr", classNameBindings: [":topic-list-item", "unboundClassNames", "topic.visited"], attributeBindings: ["data-topic-id"], "data-topic-id": alias("topic.id"), + didReceiveAttrs() { + this._super(...arguments); + this.renderTopicListItem(); + }, + + @observes("topic.pinned") + renderTopicListItem() { + const template = findRawTemplate("list/topic-list-item"); + if (template) { + this.set("topicListItemContents", template(this).htmlSafe()); + } + }, + didInsertElement() { this._super(...arguments); @@ -195,6 +207,14 @@ export const ListItemDefaults = { return this.unhandledRowClick(e, topic); }, + actions: { + toggleBookmark() { + this.topic.toggleBookmark().finally(() => this.renderTopicListItem()); + } + }, + + unhandledRowClick() {}, + navigateToTopic, highlight(opts = { isLastViewedTopic: false }) { @@ -223,27 +243,4 @@ export const ListItemDefaults = { this.highlight(); } }) -}; - -export default Component.extend( - ListItemDefaults, - bufferedRender({ - rerenderTriggers: ["bulkSelectEnabled", "topic.pinned"], - - actions: { - toggleBookmark() { - this.topic.toggleBookmark().finally(() => this.rerenderBuffer()); - } - }, - - buildBuffer(buffer) { - const template = findRawTemplate("list/topic-list-item"); - if (template) { - buffer.push(template(this)); - } - }, - - // Can be overwritten by plugins to handle clicks on other parts of the row - unhandledRowClick() {} - }) -); +}); diff --git a/app/assets/javascripts/discourse/templates/components/topic-list-item.hbs b/app/assets/javascripts/discourse/templates/components/topic-list-item.hbs new file mode 100644 index 0000000000..556c0177f9 --- /dev/null +++ b/app/assets/javascripts/discourse/templates/components/topic-list-item.hbs @@ -0,0 +1 @@ +{{topicListItemContents}}