diff --git a/app/assets/javascripts/discourse/app/components/site-header.js b/app/assets/javascripts/discourse/app/components/site-header.js index aa2016c311a..d51061671df 100644 --- a/app/assets/javascripts/discourse/app/components/site-header.js +++ b/app/assets/javascripts/discourse/app/components/site-header.js @@ -239,7 +239,7 @@ const SiteHeaderComponent = MountWidget.extend( const headerService = getOwner(this).lookup("service:header"); headerService.addObserver("topicInfoVisible", this, "setTopic"); - headerService.topicInfoVisible; // Access property to set up observer + this.setTopic(); this.appEvents.on("user-menu:rendered", this, "_animateMenu"); diff --git a/app/assets/javascripts/discourse/app/routes/topic-from-params.js b/app/assets/javascripts/discourse/app/routes/topic-from-params.js index 302c30681a4..d2411b947ee 100644 --- a/app/assets/javascripts/discourse/app/routes/topic-from-params.js +++ b/app/assets/javascripts/discourse/app/routes/topic-from-params.js @@ -46,7 +46,10 @@ export default class TopicFromParams extends DiscourseRoute { 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() { diff --git a/app/assets/javascripts/discourse/app/services/header.js b/app/assets/javascripts/discourse/app/services/header.js index 16daf0a5750..e894b5c8af5 100644 --- a/app/assets/javascripts/discourse/app/services/header.js +++ b/app/assets/javascripts/discourse/app/services/header.js @@ -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 * on initial load. The IntersectionObserver will correct this later if needed. */ - enterTopic(topic, postNumber) { + enterTopic(topic, isLoadingFirstPost) { this.topicInfo = topic; - this.mainTopicTitleVisible = !postNumber || postNumber === 1; + this.mainTopicTitleVisible = isLoadingFirstPost; } clearTopic() {