mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: makes highlighting last viewed topic more resilient (#8624)
`highlight` was called from `didInsertElement` which technically doesn't ensure the list is rendered. By wrapping the highlighting code in `afterRender` we ensure it works more consistently.
This commit is contained in:
parent
473e39f4a4
commit
6fa5725292
@ -1,6 +1,7 @@
|
|||||||
import discourseComputed from "discourse-common/utils/decorators";
|
import discourseComputed from "discourse-common/utils/decorators";
|
||||||
import { alias } from "@ember/object/computed";
|
import { alias } from "@ember/object/computed";
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
|
import { schedule } from "@ember/runloop";
|
||||||
import DiscourseURL from "discourse/lib/url";
|
import DiscourseURL from "discourse/lib/url";
|
||||||
import { bufferedRender } from "discourse-common/lib/buffered-render";
|
import { bufferedRender } from "discourse-common/lib/buffered-render";
|
||||||
import { findRawTemplate } from "discourse/lib/raw-templates";
|
import { findRawTemplate } from "discourse/lib/raw-templates";
|
||||||
@ -197,12 +198,18 @@ export const ListItemDefaults = {
|
|||||||
navigateToTopic,
|
navigateToTopic,
|
||||||
|
|
||||||
highlight(opts = { isLastViewedTopic: false }) {
|
highlight(opts = { isLastViewedTopic: false }) {
|
||||||
|
schedule("afterRender", () => {
|
||||||
|
if (!this.element || this.isDestroying || this.isDestroyed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const $topic = $(this.element);
|
const $topic = $(this.element);
|
||||||
$topic
|
$topic
|
||||||
.addClass("highlighted")
|
.addClass("highlighted")
|
||||||
.attr("data-islastviewedtopic", opts.isLastViewedTopic);
|
.attr("data-islastviewedtopic", opts.isLastViewedTopic);
|
||||||
|
|
||||||
$topic.on("animationend", () => $topic.removeClass("highlighted"));
|
$topic.on("animationend", () => $topic.removeClass("highlighted"));
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
_highlightIfNeeded: on("didInsertElement", function() {
|
_highlightIfNeeded: on("didInsertElement", function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user