UX: Display only top categories in hamburger menu (#6146)

This commit is contained in:
Vinoth Kannan
2018-07-27 12:11:07 +05:30
committed by GitHub
parent e4208113a8
commit dac29b5ebc
7 changed files with 122 additions and 46 deletions

View File

@ -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