mirror of
https://github.com/discourse/discourse.git
synced 2025-06-08 00:27:32 +08:00
FIX: Hide muted subcategories (#8239)
That bug was mentioned in [meta](https://meta.discourse.org/t/muting-categories-hides-them-muting-subcategories-should-too/131316) Problem is that subcategories are always visible in `/categories` path even if muted. Categories/subcategories are loaded in at least two places https://github.com/discourse/discourse/blob/master/app/assets/javascripts/discourse/models/site.js.es6#L146 https://github.com/discourse/discourse/blob/master/app/assets/javascripts/discourse/routes/discovery-categories.js.es6#L46 I discussed that with @jjaffeux and we thought that maybe it would be a good idea to filter that on frontend level
This commit is contained in:

committed by
GitHub

parent
7b04bb7290
commit
ae108b363f
@ -3,6 +3,7 @@ import RestModel from "discourse/models/rest";
|
|||||||
import computed from "ember-addons/ember-computed-decorators";
|
import computed from "ember-addons/ember-computed-decorators";
|
||||||
import { on } from "ember-addons/ember-computed-decorators";
|
import { on } from "ember-addons/ember-computed-decorators";
|
||||||
import PermissionType from "discourse/models/permission-type";
|
import PermissionType from "discourse/models/permission-type";
|
||||||
|
import { NotificationLevels } from "discourse/lib/notification-levels";
|
||||||
|
|
||||||
const Category = RestModel.extend({
|
const Category = RestModel.extend({
|
||||||
permissions: null,
|
permissions: null,
|
||||||
@ -44,6 +45,11 @@ const Category = RestModel.extend({
|
|||||||
return { type: "category", id, category: this };
|
return { type: "category", id, category: this };
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@computed("notification_level")
|
||||||
|
isMuted(notificationLevel) {
|
||||||
|
return notificationLevel === NotificationLevels.MUTED;
|
||||||
|
},
|
||||||
|
|
||||||
@computed("name")
|
@computed("name")
|
||||||
url() {
|
url() {
|
||||||
return Discourse.getURL("/c/") + Category.slugFor(this);
|
return Discourse.getURL("/c/") + Category.slugFor(this);
|
||||||
|
@ -20,12 +20,14 @@
|
|||||||
</div>
|
</div>
|
||||||
{{#if c.subcategories}}
|
{{#if c.subcategories}}
|
||||||
<div class='subcategories'>
|
<div class='subcategories'>
|
||||||
{{#each c.subcategories as |s|}}
|
{{#each c.subcategories as |subcategory|}}
|
||||||
|
{{#unless subcategory.isMuted}}
|
||||||
<span class='subcategory'>
|
<span class='subcategory'>
|
||||||
{{category-title-before category=s}}
|
{{category-title-before category=subcategory}}
|
||||||
{{category-link s hideParent="true"}}
|
{{category-link subcategory hideParent="true"}}
|
||||||
{{category-unread category=s}}
|
{{category-unread category=subcategory}}
|
||||||
</span>
|
</span>
|
||||||
|
{{/unless}}
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
Reference in New Issue
Block a user