mirror of
https://github.com/discourse/discourse.git
synced 2025-02-17 03:42:45 +08:00
UX: Avoid header topic-info flicker when using ?page=
params (#28117)
In this case, there is no 'nearPost' param in the URL. Instead, the server preloads a post-stream with whichever page of posts is requested. We can check for that situation using `postStream.firstPostPresent`.
Also updates the widget-header version to fetch a value from the service on initial render, instead of relying on the observer triggering.
Followup to bdec564d14
This commit is contained in:
parent
5b51ed3856
commit
b44190307f
|
@ -239,7 +239,7 @@ const SiteHeaderComponent = MountWidget.extend(
|
||||||
|
|
||||||
const headerService = getOwner(this).lookup("service:header");
|
const headerService = getOwner(this).lookup("service:header");
|
||||||
headerService.addObserver("topicInfoVisible", this, "setTopic");
|
headerService.addObserver("topicInfoVisible", this, "setTopic");
|
||||||
headerService.topicInfoVisible; // Access property to set up observer
|
this.setTopic();
|
||||||
|
|
||||||
this.appEvents.on("user-menu:rendered", this, "_animateMenu");
|
this.appEvents.on("user-menu:rendered", this, "_animateMenu");
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,10 @@ export default class TopicFromParams extends DiscourseRoute {
|
||||||
this.pmTopicTrackingState.startTracking();
|
this.pmTopicTrackingState.startTracking();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.header.enterTopic(topic, model.nearPost);
|
const isLoadingFirstPost =
|
||||||
|
topic.postStream.firstPostPresent &&
|
||||||
|
!(model.nearPost && model.nearPost > 1);
|
||||||
|
this.header.enterTopic(topic, isLoadingFirstPost);
|
||||||
}
|
}
|
||||||
|
|
||||||
deactivate() {
|
deactivate() {
|
||||||
|
|
|
@ -133,9 +133,9 @@ export default class Header extends Service {
|
||||||
* and makes a guess about whether the main topic title is likely to be visible
|
* and makes a guess about whether the main topic title is likely to be visible
|
||||||
* on initial load. The IntersectionObserver will correct this later if needed.
|
* on initial load. The IntersectionObserver will correct this later if needed.
|
||||||
*/
|
*/
|
||||||
enterTopic(topic, postNumber) {
|
enterTopic(topic, isLoadingFirstPost) {
|
||||||
this.topicInfo = topic;
|
this.topicInfo = topic;
|
||||||
this.mainTopicTitleVisible = !postNumber || postNumber === 1;
|
this.mainTopicTitleVisible = isLoadingFirstPost;
|
||||||
}
|
}
|
||||||
|
|
||||||
clearTopic() {
|
clearTopic() {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user