DEV: Don't eagerly find and assign Topic.category
This commit is contained in:
parent
19b7cdd21f
commit
cb4c9eeab8
|
@ -241,11 +241,10 @@ export default Controller.extend(ModalFunctionality, {
|
|||
|
||||
changeCategory() {
|
||||
const categoryId = parseInt(this.newCategoryId, 10) || 0;
|
||||
const category = Category.findById(categoryId);
|
||||
|
||||
this.perform({ type: "change_category", category_id: categoryId }).then(
|
||||
(topics) => {
|
||||
topics.forEach((t) => t.set("category", category));
|
||||
topics.forEach((t) => t.set("category_id", categoryId));
|
||||
(this.refreshClosure || identity)();
|
||||
this.send("closeModal");
|
||||
}
|
||||
|
|
|
@ -43,11 +43,7 @@ CategoryList.reopenClass({
|
|||
}
|
||||
|
||||
if (c.topics) {
|
||||
c.topics = c.topics.map((t) => {
|
||||
const topic = Topic.create(t);
|
||||
topic.set("category", c);
|
||||
return topic;
|
||||
});
|
||||
c.topics = c.topics.map((t) => Topic.create(t));
|
||||
}
|
||||
|
||||
switch (statPeriod) {
|
||||
|
|
|
@ -5,7 +5,6 @@ import { ajax } from "discourse/lib/ajax";
|
|||
import RestModel from "discourse/models/rest";
|
||||
import { getOwner } from "discourse-common/lib/get-owner";
|
||||
import { Promise } from "rsvp";
|
||||
import Category from "discourse/models/category";
|
||||
import Session from "discourse/models/session";
|
||||
import { isEmpty } from "@ember/utils";
|
||||
import User from "discourse/models/user";
|
||||
|
@ -156,12 +155,10 @@ TopicList.reopenClass({
|
|||
|
||||
// Stitch together our side loaded data
|
||||
|
||||
const categories = Category.list(),
|
||||
users = extractByKey(result.users, User),
|
||||
groups = extractByKey(result.primary_groups, EmberObject);
|
||||
const users = extractByKey(result.users, User);
|
||||
const groups = extractByKey(result.primary_groups, EmberObject);
|
||||
|
||||
return result.topic_list[listKey].map((t) => {
|
||||
t.category = categories.findBy("id", t.category_id);
|
||||
t.posters.forEach((p) => {
|
||||
p.user = users[p.user_id];
|
||||
p.extraClasses = p.extras;
|
||||
|
|
Loading…
Reference in New Issue