mirror of
https://github.com/discourse/discourse-ai.git
synced 2025-06-25 09:02:23 +00:00
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:
parent
55dab9c68a
commit
b817810d46
@ -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(
|
||||
|
Loading…
x
Reference in New Issue
Block a user