Use new method to fetch collection watchers
This commit is contained in:
@@ -27,10 +27,7 @@ module AccessesHelper
|
||||
end
|
||||
|
||||
def collection_watchers_list(collection)
|
||||
watchers = collection.users
|
||||
.without(User.system)
|
||||
.where(accesses: { involvement: :watching })
|
||||
.distinct
|
||||
watchers = collection.watchers
|
||||
|
||||
displayed_watchers = watchers.limit(MAX_DISPLAYED_WATCHERS)
|
||||
overflow_count = watchers.count - MAX_DISPLAYED_WATCHERS
|
||||
@@ -50,13 +47,13 @@ module AccessesHelper
|
||||
collection_involvement_path(collection),
|
||||
method: :put,
|
||||
aria: { labelledby: involvement_label_id },
|
||||
class: class_names("btn", { "btn--reversed": access.involvement == "watching" && icon_only }),
|
||||
class: class_names("btn", { "btn--reversed": access.watching? && icon_only }),
|
||||
params: { show_watchers: show_watchers, involvement: next_involvement(access.involvement), icon_only: icon_only }
|
||||
) do
|
||||
safe_join([
|
||||
icon_tag("notification-bell-#{icon_only ? 'reverse-' : nil}#{access.involvement.dasherize}"),
|
||||
tag.span(
|
||||
involvement_access_label(collection, access.involvement),
|
||||
involvement_access_label(access),
|
||||
class: class_names("txt-nowrap txt-uppercase", "for-screen-reader": icon_only),
|
||||
id: involvement_label_id
|
||||
)
|
||||
@@ -70,12 +67,11 @@ module AccessesHelper
|
||||
order[(order.index(involvement.to_s) + 1) % order.size]
|
||||
end
|
||||
|
||||
def involvement_access_label(collection, involvement)
|
||||
case involvement
|
||||
when "access_only"
|
||||
def involvement_access_label(access)
|
||||
if access.access_only?
|
||||
"Watch this"
|
||||
when "watching"
|
||||
"Stop Watching"
|
||||
else
|
||||
"Stop watching"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -48,7 +48,7 @@ module Collection::Accessible
|
||||
end
|
||||
|
||||
def watchers
|
||||
users.where(accesses: { involvement: :watching })
|
||||
users.without(User.system).where(accesses: { involvement: :watching })
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
Reference in New Issue
Block a user