FIX: ensures topic info is dynamic with scroll (#27082)

Prior to this fix we were using `topic.current_post_number` which is coming from the server side and represents the initial topic scroll position when initially rendered to the end user. However, this value is not dynamic and is not updated when the user scrolls, `topic.currentPost` is the dynamic equivalent.

No test as there are very low chances a test like this one based on scroll position, will be reliable over time.
This commit is contained in:
Joffrey JAFFEUX 2024-05-20 11:20:37 +02:00 committed by GitHub
parent 29bf61d5dd
commit 9302187ca4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,14 +1,14 @@
import { getOwner } from "@ember/application";
export function extractCurrentTopicInfo(context) {
const topic = getOwner(context).lookup("controller:topic")?.get("model");
const topic = getOwner(context).lookup("controller:topic")?.model;
if (!topic) {
return;
}
const info = { context_topic_id: topic.id };
const currentPostNumber = parseInt(topic.current_post_number, 10);
const currentPostNumber = topic.currentPost;
const posts = topic.postStream.posts;
const currentPost = posts.find(