DEV: Prefer Ember's RSVP over native Promise (#25049)

This causes an incompatibility in some plugins that are patching the
discovery-categories route, such as discourse-global-filter.
This commit is contained in:
Bianca Nenciu 2023-12-28 14:15:35 +02:00 committed by GitHub
parent 1061bf97e2
commit c4396c6acf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 26 additions and 21 deletions

View File

@ -80,30 +80,35 @@ export default class DiscoveryCategoriesRoute extends DiscourseRoute {
}
async _findCategoriesAndTopics(filter) {
let result = await hash({
return hash({
categoriesList: PreloadStore.getAndRemove("categories_list"),
topicsList: PreloadStore.getAndRemove("topic_list"),
});
})
.then((result) => {
if (
result.categoriesList?.category_list &&
result.topicsList?.topic_list
) {
return { ...result.categoriesList, ...result.topicsList };
} else {
// Otherwise, return the ajax result
return ajax(`/categories_and_${filter}`);
}
})
.then((result) => {
if (result.topic_list?.top_tags) {
this.site.set("top_tags", result.topic_list.top_tags);
}
if (result.categoriesList?.category_list && result.topicsList?.topic_list) {
result = { ...result.categoriesList, ...result.topicsList };
} else {
// Otherwise, return the ajax result
result = await ajax(`/categories_and_${filter}`);
}
if (result.topic_list?.top_tags) {
this.site.set("top_tags", result.topic_list.top_tags);
}
return CategoryList.create({
store: this.store,
categories: CategoryList.categoriesFrom(this.store, result),
topics: TopicList.topicsFrom(this.store, result),
can_create_category: result.category_list.can_create_category,
can_create_topic: result.category_list.can_create_topic,
loadBefore: this._loadBefore(this.store),
});
return CategoryList.create({
store: this.store,
categories: CategoryList.categoriesFrom(this.store, result),
topics: TopicList.topicsFrom(this.store, result),
can_create_category: result.category_list.can_create_category,
can_create_topic: result.category_list.can_create_topic,
loadBefore: this._loadBefore(this.store),
});
});
}
titleToken() {