mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Load category before opening composer (#26493)
The "new topic" route can open the composer with a category preselected. This commit ensures that the category is loaded before the composer is opened.
This commit is contained in:
parent
339893812b
commit
52aefa720d
@ -10,9 +10,23 @@ export default class extends DiscourseRoute {
|
|||||||
@service currentUser;
|
@service currentUser;
|
||||||
@service site;
|
@service site;
|
||||||
|
|
||||||
beforeModel(transition) {
|
async beforeModel(transition) {
|
||||||
if (this.currentUser) {
|
if (this.currentUser) {
|
||||||
const category = this.parseCategoryFromTransition(transition);
|
let category;
|
||||||
|
if (this.site.lazy_load_categories) {
|
||||||
|
if (transition.to.queryParams.category_id) {
|
||||||
|
const categories = await Category.asyncFindByIds([
|
||||||
|
transition.to.queryParams.category_id,
|
||||||
|
]);
|
||||||
|
category = categories[0];
|
||||||
|
} else if (transition.to.queryParams.category) {
|
||||||
|
category = await Category.asyncFindBySlugPath(
|
||||||
|
transition.to.queryParams.category
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
category = this.parseCategoryFromTransition(transition);
|
||||||
|
}
|
||||||
|
|
||||||
if (category) {
|
if (category) {
|
||||||
// Using URL-based transition to avoid bug with dynamic segments and refreshModel query params
|
// Using URL-based transition to avoid bug with dynamic segments and refreshModel query params
|
||||||
|
Loading…
Reference in New Issue
Block a user