DEV: Update glimmer topic timeline visibility state when a post is created (#20145)

# Problem
Creating a post on a topic, where the timeline is not shown by default, does not update the visibility state dynamically. You must refresh the page to have the timeline appear. 

# Solution 
This PR hooks into the `post-stream:posted` app event and checks if we can now display the timeline after a post has been created. This will update the visibility state dynamically.
This commit is contained in:
Isaac Janzen 2023-02-02 14:02:51 -06:00 committed by GitHub
parent e82865726c
commit 8226fca6ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -45,6 +45,7 @@ export default class TopicTimelineScrollArea extends Component {
this.appEvents.on("composer:opened", this.calculatePosition); this.appEvents.on("composer:opened", this.calculatePosition);
this.appEvents.on("composer:resized", this.calculatePosition); this.appEvents.on("composer:resized", this.calculatePosition);
this.appEvents.on("composer:closed", this.calculatePosition); this.appEvents.on("composer:closed", this.calculatePosition);
this.appEvents.on("post-stream:posted", this.calculatePosition);
} }
this.calculatePosition(); this.calculatePosition();
@ -55,8 +56,7 @@ export default class TopicTimelineScrollArea extends Component {
return true; return true;
} }
const streamLength = this.args.model.postStream?.stream?.length; if (this.total === 1) {
if (streamLength === 1) {
const postsWrapper = document.querySelector(".posts-wrapper"); const postsWrapper = document.querySelector(".posts-wrapper");
if (postsWrapper && postsWrapper.offsetHeight < 1000) { if (postsWrapper && postsWrapper.offsetHeight < 1000) {
return false; return false;
@ -302,6 +302,7 @@ export default class TopicTimelineScrollArea extends Component {
this.appEvents.off("composer:resized", this.calculatePosition); this.appEvents.off("composer:resized", this.calculatePosition);
this.appEvents.off("composer:closed", this.calculatePosition); this.appEvents.off("composer:closed", this.calculatePosition);
this.appEvents.off("topic:current-post-scrolled", this.postScrolled); this.appEvents.off("topic:current-post-scrolled", this.postScrolled);
this.appEvents.off("post-stream:posted", this.calculatePosition);
} }
} }