FIX: Keep related topics data cached when a user scrolls up (#976)

See https://meta.discourse.org/t/related-topics-missing-after-rereading-a-topic-with-more-than-20-posts/306147/6
This commit is contained in:
Rafael dos Santos Silva 2024-11-28 14:25:15 -03:00 committed by GitHub
parent eacc4ed945
commit 6456a4f44a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 1 deletions

View File

@ -47,10 +47,16 @@ export default {
(Superclass) =>
class extends Superclass {
@tracked related_topics;
relatedTopicsCache = [];
@cached
get relatedTopics() {
return this.related_topics?.map((topic) =>
// Used to keep related topics when a user scrolls up from the
// bottom of the topic and then scrolls back down
if (this.related_topics) {
this.relatedTopicsCache = this.related_topics;
}
return this.relatedTopicsCache?.map((topic) =>
this.store.createRecord("topic", topic)
);
}