mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 18:30:26 -06:00
FIX: Ensure header topic info updates immediately when navigating away (#26128)
Changing an `@tracked` value in a `willDestroyElement` hook will not immediately trigger a re-render. Instead, it seems to update on the next natural runloop iteration, which may be significantly later depending on what else is happening. Instead, these kinds of 'data' changes should be made based on the lifecycle of the component instance (init / willDestroy). Making changes to tracked properties here does seem to cause immediate invalidation & re-render.
This commit is contained in:
parent
8b4730e52c
commit
eba0131561
@ -96,6 +96,13 @@ export default Component.extend(Scrolling, MobileScrollDirection, {
|
||||
}
|
||||
},
|
||||
|
||||
init() {
|
||||
this._super(...arguments);
|
||||
this.appEvents.on("discourse:focus-changed", this, "gotFocus");
|
||||
this.appEvents.on("post:highlight", this, "_highlightPost");
|
||||
this.appEvents.on("header:update-topic", this, "_updateTopic");
|
||||
},
|
||||
|
||||
didInsertElement() {
|
||||
this._super(...arguments);
|
||||
|
||||
@ -106,9 +113,16 @@ export default Component.extend(Scrolling, MobileScrollDirection, {
|
||||
".cooked a, a.track-link",
|
||||
(e) => ClickTrack.trackClick(e, getOwner(this))
|
||||
);
|
||||
this.appEvents.on("discourse:focus-changed", this, "gotFocus");
|
||||
this.appEvents.on("post:highlight", this, "_highlightPost");
|
||||
this.appEvents.on("header:update-topic", this, "_updateTopic");
|
||||
},
|
||||
|
||||
willDestroy() {
|
||||
this._super(...arguments);
|
||||
|
||||
// this happens after route exit, stuff could have trickled in
|
||||
this._hideTopicInHeader();
|
||||
this.appEvents.off("discourse:focus-changed", this, "gotFocus");
|
||||
this.appEvents.off("post:highlight", this, "_highlightPost");
|
||||
this.appEvents.off("header:update-topic", this, "_updateTopic");
|
||||
},
|
||||
|
||||
willDestroyElement() {
|
||||
@ -121,12 +135,6 @@ export default Component.extend(Scrolling, MobileScrollDirection, {
|
||||
$(this.element).off("click.discourse-redirect", ".cooked a, a.track-link");
|
||||
|
||||
this.resetExamineDockCache();
|
||||
|
||||
// this happens after route exit, stuff could have trickled in
|
||||
this._hideTopicInHeader();
|
||||
this.appEvents.off("discourse:focus-changed", this, "gotFocus");
|
||||
this.appEvents.off("post:highlight", this, "_highlightPost");
|
||||
this.appEvents.off("header:update-topic", this, "_updateTopic");
|
||||
},
|
||||
|
||||
gotFocus(hasFocus) {
|
||||
|
Loading…
Reference in New Issue
Block a user