A platform for community discussion. Free, open, simple.
FIX: makes highlighting last viewed topic more resilient (#8624)
Joffrey JAFFEUX6fa572529283
diff --git a/app/assets/javascripts/discourse/components/topic-list-item.js.es6 b/app/assets/javascripts/discourse/components/topic-list-item.js.es6index 670d45b64cf..2909dce548e 100644--- a/app/assets/javascripts/discourse/components/topic-list-item.js.es6+++ b/app/assets/javascripts/discourse/components/topic-list-item.js.es6@@ -1,6 +1,7 @@import discourseComputed 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";@@ -197,12 +198,18 @@ export const ListItemDefaults = {navigateToTopic,highlight(opts = { isLastViewedTopic: false }) {- const $topic = $(this.element);- $topic- .addClass("highlighted")- .attr("data-islastviewedtopic", opts.isLastViewedTopic);+ schedule("afterRender", () => {+ if (!this.element || this.isDestroying || this.isDestroyed) {+ return;+ }++ const $topic = $(this.element);+ $topic+ .addClass("highlighted")+ .attr("data-islastviewedtopic", opts.isLastViewedTopic);- $topic.on("animationend", () => $topic.removeClass("highlighted"));+ $topic.on("animationend", () => $topic.removeClass("highlighted"));+ });},_highlightIfNeeded: on("didInsertElement", function() {