mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
UX: Display only top categories in hamburger menu (#6146)
This commit is contained in:
@ -2,6 +2,8 @@ require_dependency 'new_post_manager'
|
||||
|
||||
class CurrentUserSerializer < BasicUserSerializer
|
||||
|
||||
MAX_TOP_CATEGORIES_COUNT = 6.freeze
|
||||
|
||||
attributes :name,
|
||||
:unread_notifications,
|
||||
:unread_private_messages,
|
||||
@ -41,7 +43,8 @@ class CurrentUserSerializer < BasicUserSerializer
|
||||
:primary_group_name,
|
||||
:can_create_topic,
|
||||
:link_posting_access,
|
||||
:external_id
|
||||
:external_id,
|
||||
:top_category_ids
|
||||
|
||||
def link_posting_access
|
||||
scope.link_posting_access
|
||||
@ -153,9 +156,20 @@ class CurrentUserSerializer < BasicUserSerializer
|
||||
end
|
||||
|
||||
def muted_category_ids
|
||||
@muted_category_ids ||= CategoryUser.where(user_id: object.id,
|
||||
notification_level: TopicUser.notification_levels[:muted])
|
||||
CategoryUser.lookup(object, :muted).pluck(:category_id)
|
||||
end
|
||||
|
||||
def top_category_ids
|
||||
CategoryUser.where(user_id: object.id)
|
||||
.where.not(notification_level: CategoryUser.notification_levels[:muted])
|
||||
.order("
|
||||
CASE
|
||||
WHEN notification_level = 3 THEN 1
|
||||
WHEN notification_level = 2 THEN 2
|
||||
WHEN notification_level = 4 THEN 3
|
||||
END")
|
||||
.pluck(:category_id)
|
||||
.slice(0, MAX_TOP_CATEGORIES_COUNT)
|
||||
end
|
||||
|
||||
def dismissed_banner_key
|
||||
|
Reference in New Issue
Block a user