A platform for community discussion. Free, open, simple.
FIX: make update banner always available on the categories view (#14431)
Jeanfd0e287da672
diff --git a/app/assets/javascripts/discourse/app/routes/discovery-categories.js b/app/assets/javascripts/discourse/app/routes/discovery-categories.jsindex 92081b73c52..aeb2351552f 100644--- a/app/assets/javascripts/discourse/app/routes/discovery-categories.js+++ b/app/assets/javascripts/discourse/app/routes/discovery-categories.js@@ -43,7 +43,35 @@ const DiscoveryCategoriesRoute = DiscourseRoute.extend(OpenComposer, {return model;});},+ _loadBefore(store) {+ return function (topic_ids, storeInSession) {+ // refresh dupes+ this.topics.removeObjects(+ this.topics.filter((topic) => topic_ids.indexOf(topic.id) >= 0)+ );++ const url = `${getURL("/")}latest.json?topic_ids=${topic_ids.join(",")}`;++ return ajax({ url, data: this.params }).then((result) => {+ const topicIds = [];++ this.topics.forEach((topic) => (topicIds[topic.id] = true));++ let i = 0;+ TopicList.topicsFrom(store, result).forEach((topic) => {+ if (!topicIds[topic.id]) {+ topic.set("highlight", true);+ this.topics.insertAt(i, topic);+ i++;+ }+ });+ if (storeInSession) {+ Session.currentProp("topicList", this);+ }+ });+ };+ },_findCategoriesAndTopics(filter) {return hash({wrappedCategoriesList: PreloadStore.getAndRemove("categories_list"),@@ -52,51 +80,22 @@ const DiscoveryCategoriesRoute = DiscourseRoute.extend(OpenComposer, {let { wrappedCategoriesList, topicsList } = response;let categoriesList =wrappedCategoriesList && wrappedCategoriesList.category_list;+ let store = this.store;if (categoriesList && topicsList) {if (topicsList.topic_list && topicsList.topic_list.top_tags) {Site.currentProp("top_tags", topicsList.topic_list.top_tags);}- let store = this.store;-return EmberObject.create({categories: CategoryList.categoriesFrom(this.store,wrappedCategoriesList),- loadBefore: function (topic_ids, storeInSession) {- // refresh dupes- this.topics.removeObjects(- this.topics.filter((topic) => topic_ids.indexOf(topic.id) >= 0)- );-- const url = `${getURL("/")}latest.json?topic_ids=${topic_ids.join(- ","- )}`;-- return ajax({ url, data: this.params }).then((result) => {- const topicIds = [];-- this.topics.forEach((topic) => (topicIds[topic.id] = true));-- let i = 0;- TopicList.topicsFrom(store, result).forEach((topic) => {- if (!topicIds[topic.id]) {- topic.set("highlight", true);- this.topics.insertAt(i, topic);- i++;- }- });-- if (storeInSession) {- Session.currentProp("topicList", this);- }- });- },topics: TopicList.topicsFrom(this.store, topicsList),can_create_category: categoriesList.can_create_category,can_create_topic: categoriesList.can_create_topic,+ loadBefore: this._loadBefore(store),});}// Otherwise, return the ajax result@@ -110,6 +109,7 @@ const DiscoveryCategoriesRoute = DiscourseRoute.extend(OpenComposer, {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(store),});});});