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:
parent
eacc4ed945
commit
6456a4f44a
|
@ -47,10 +47,16 @@ export default {
|
||||||
(Superclass) =>
|
(Superclass) =>
|
||||||
class extends Superclass {
|
class extends Superclass {
|
||||||
@tracked related_topics;
|
@tracked related_topics;
|
||||||
|
relatedTopicsCache = [];
|
||||||
|
|
||||||
@cached
|
@cached
|
||||||
get relatedTopics() {
|
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)
|
this.store.createRecord("topic", topic)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue