FIX: Wait for async `Topic.apply_transformations` during `loadMore` (#26143)

`apply_transformations` is an async function, and plugins/themes using it expect their transformations to be applied before the loadMore logic continues. This should resolve issues with unencrypted topics when scrolling down topic lists in discourse-encrypt.
This commit is contained in:
David Taylor 2024-03-12 21:31:39 +00:00 committed by GitHub
parent 0d64c886da
commit a24c16c911
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 2 deletions

View File

@ -185,13 +185,13 @@ export default class TopicList extends RestModel {
this.set("loadingMore", true); this.set("loadingMore", true);
return ajax({ url: moreUrl }).then((result) => { return ajax({ url: moreUrl }).then(async (result) => {
let topicsAdded = 0; let topicsAdded = 0;
if (result) { if (result) {
// the new topics loaded from the server // the new topics loaded from the server
const newTopics = TopicList.topicsFrom(this.store, result); const newTopics = TopicList.topicsFrom(this.store, result);
Topic.applyTransformations(newTopics); await Topic.applyTransformations(newTopics);
this.forEachNew(newTopics, (t) => { this.forEachNew(newTopics, (t) => {
t.set("highlight", topicsAdded++ === 0); t.set("highlight", topicsAdded++ === 0);