FIX: ensures stream update object is scoped to its initial topic (#1359)

* FIX: ensures stream update object is scoped to its initial topic

Before this commit you could end up in this situation where a `post-updater` is constructed for a specific topic, but the user changes topic mid steam and it ends up updating the same post number but in a  different topic as we were only checking for `post_number` and not the combination of `topic_id` + `post_number`.

* we should have the topic
This commit is contained in:
Joffrey JAFFEUX 2025-05-22 12:08:43 +02:00 committed by GitHub
parent 55dab9c68a
commit b817810d46
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -12,13 +12,15 @@ export default class PostUpdater extends StreamUpdater {
constructor(postStream, postId) {
super();
this.postStream = postStream;
this.postId = postId;
this.post = postStream.findLoadedPost(postId);
const topicId = postStream.topic.id;
if (this.post) {
this.postElement = document.querySelector(
`#post_${this.post.post_number}`
`.topic-area[data-topic-id="${topicId}"] #post_${this.post.post_number}`
);
}
}
@ -57,6 +59,10 @@ export default class PostUpdater extends StreamUpdater {
}
async setCooked(value) {
if (!this.postElement) {
return;
}
this.post.set("cooked", value);
(await loadMorphlex()).morphInner(