Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit b817810

Browse files
authored
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
1 parent 55dab9c commit b817810

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

assets/javascripts/discourse/lib/ai-streamer/updaters/post-updater.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ export default class PostUpdater extends StreamUpdater {
1212

1313
constructor(postStream, postId) {
1414
super();
15+
1516
this.postStream = postStream;
1617
this.postId = postId;
1718
this.post = postStream.findLoadedPost(postId);
19+
const topicId = postStream.topic.id;
1820

1921
if (this.post) {
2022
this.postElement = document.querySelector(
21-
`#post_${this.post.post_number}`
23+
`.topic-area[data-topic-id="${topicId}"] #post_${this.post.post_number}`
2224
);
2325
}
2426
}
@@ -57,6 +59,10 @@ export default class PostUpdater extends StreamUpdater {
5759
}
5860

5961
async setCooked(value) {
62+
if (!this.postElement) {
63+
return;
64+
}
65+
6066
this.post.set("cooked", value);
6167

6268
(await loadMorphlex()).morphInner(

0 commit comments

Comments
 (0)