FIX: Remove tags from experimental sidebar on notification level changed (#17083)

As part of this commit, a bug where updating a tag's notification level on the server side does not update the state of the user's tag notification levels on the client side is fixed too.
This commit is contained in:
Alan Guo Xiang Tan
2022-06-14 15:39:56 +08:00
committed by GitHub
parent 47034d9ca0
commit e7e23e8d9c
12 changed files with 167 additions and 78 deletions

View File

@ -1,6 +1,7 @@
# frozen_string_literal: true
class CurrentUserSerializer < BasicUserSerializer
include UserTagNotificationsMixin
attributes :name,
:unread_notifications,
@ -33,7 +34,6 @@ class CurrentUserSerializer < BasicUserSerializer
:tracked_category_ids,
:watched_first_post_category_ids,
:watched_category_ids,
:muted_tag_ids,
:watched_tags,
:watching_first_post_tags,
:tracked_tags,
@ -230,32 +230,6 @@ class CurrentUserSerializer < BasicUserSerializer
categories_with_notification_level(:watching_first_post)
end
# this is a weird outlier that is used for topic tracking state which
# needs the actual ids, which is why it is duplicated with muted_tags
def muted_tag_ids
TagUser.lookup(object, :muted).pluck(:tag_id)
end
def muted_tags
tags_with_notification_level(:muted)
end
def tracked_tags
tags_with_notification_level(:tracking)
end
def watching_first_post_tags
tags_with_notification_level(:watching_first_post)
end
def watched_tags
tags_with_notification_level(:watching)
end
def regular_tags
tags_with_notification_level(:regular)
end
def ignored_users
IgnoredUser.where(user: object.id).joins(:ignored_user).pluck(:username)
end