DEV: Ensure current-post-changed is fired when switching between topics (#23930)

Previously this logic was only checking the post number. That meant that navigating between the first post of two topics would not trigger the event.

In the past, the event would be triggered anyway because the ScrollingPostStream would be destroyed/re-created when navigating between topics. But now that we use the 'loading slider' technique, the same component instance is re-used.

The motivation for this commit is to fix the 'DiscoToc' theme component, which relies on the event firing when navigating between topics.
This commit is contained in:
David Taylor 2023-10-13 15:45:32 +01:00 committed by GitHub
parent ec8ae3fc65
commit b3df0a362b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 6 deletions

View File

@ -37,7 +37,7 @@ export default MountWidget.extend({
widget: "post-stream",
_topVisible: null,
_bottomVisible: null,
_currentPost: null,
_currentPostObj: null,
_currentVisible: null,
_currentPercent: null,
@ -219,11 +219,11 @@ export default MountWidget.extend({
this.bottomVisibleChanged({ post: last, refresh });
}
const changedPost = this._currentPost !== currentPost;
const currentPostObj = posts.objectAt(currentPost);
const changedPost = this._currentPostObj !== currentPostObj;
if (changedPost) {
this._currentPost = currentPost;
const post = posts.objectAt(currentPost);
this.currentPostChanged({ post });
this._currentPostObj = currentPostObj;
this.currentPostChanged({ post: currentPostObj });
}
if (percent !== null) {
@ -237,7 +237,7 @@ export default MountWidget.extend({
} else {
this._topVisible = null;
this._bottomVisible = null;
this._currentPost = null;
this._currentPostObj = null;
this._currentPercent = null;
}