mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 04:31:10 +08:00
DEV: Use Category.findById instead of Array.find (#26445)
Category.findById uses a Map to look up categories by ID which makes it faster and preferable over Site.categories.find.
This commit is contained in:
@ -8,6 +8,7 @@ import { isBlank, isPresent } from "@ember/utils";
|
||||
import { ajax } from "discourse/lib/ajax";
|
||||
import { extractError } from "discourse/lib/ajax-error";
|
||||
import { escapeExpression } from "discourse/lib/utilities";
|
||||
import Category from "discourse/models/category";
|
||||
import discourseDebounce from "discourse-common/lib/debounce";
|
||||
import I18n from "discourse-i18n";
|
||||
|
||||
@ -67,9 +68,7 @@ export default class ChatModalCreateChannel extends Component {
|
||||
|
||||
@action
|
||||
onCategoryChange(categoryId) {
|
||||
const category = categoryId
|
||||
? this.site.categories.findBy("id", categoryId)
|
||||
: null;
|
||||
const category = categoryId ? Category.findById(categoryId) : null;
|
||||
this.#updatePermissionsHint(category);
|
||||
|
||||
const name = this.name || category?.name || "";
|
||||
|
Reference in New Issue
Block a user