From a24c16c911b5db53d26499f7650649e6fa94d7a4 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Tue, 12 Mar 2024 21:31:39 +0000 Subject: [PATCH] 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. --- app/assets/javascripts/discourse/app/models/topic-list.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/discourse/app/models/topic-list.js b/app/assets/javascripts/discourse/app/models/topic-list.js index f649b38223f..bffccb495f9 100644 --- a/app/assets/javascripts/discourse/app/models/topic-list.js +++ b/app/assets/javascripts/discourse/app/models/topic-list.js @@ -185,13 +185,13 @@ export default class TopicList extends RestModel { this.set("loadingMore", true); - return ajax({ url: moreUrl }).then((result) => { + return ajax({ url: moreUrl }).then(async (result) => { let topicsAdded = 0; if (result) { // the new topics loaded from the server const newTopics = TopicList.topicsFrom(this.store, result); - Topic.applyTransformations(newTopics); + await Topic.applyTransformations(newTopics); this.forEachNew(newTopics, (t) => { t.set("highlight", topicsAdded++ === 0);