summaryrefslogtreecommitdiffstats
path: root/app/helpers/reactions_helper.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/helpers/reactions_helper.rb')
-rw-r--r--app/helpers/reactions_helper.rb14
1 files changed, 7 insertions, 7 deletions
diff --git a/app/helpers/reactions_helper.rb b/app/helpers/reactions_helper.rb
index 911da7127..88d7f5c35 100644
--- a/app/helpers/reactions_helper.rb
+++ b/app/helpers/reactions_helper.rb
@@ -26,15 +26,15 @@ module ReactionsHelper
detail = object.reaction_detail
- reaction = detail.user_reaction
+ user_reaction = detail.user_reaction
count = detail.reaction_count
visible_user_names = detail.visible_users.take(DISPLAY_REACTION_USERS_LIMIT).map(&:name)
tooltip = build_reaction_tooltip(visible_user_names, count)
- if Redmine::Reaction.writable?(object, User.current)
- if reaction&.persisted?
- reaction_button_reacted(object, reaction, count, tooltip)
+ if Redmine::Reaction.editable?(object, User.current)
+ if user_reaction.present?
+ reaction_button_reacted(object, user_reaction, count, tooltip)
else
reaction_button_not_reacted(object, count, tooltip)
end
@@ -52,7 +52,7 @@ module ReactionsHelper
def reaction_button_reacted(object, reaction, count, tooltip)
reaction_button_wrapper object do
link_to(
- sprite_icon('thumb-up-filled', count),
+ sprite_icon('thumb-up-filled', count.nonzero?),
reaction_path(reaction, object_type: object.class.name, object_id: object),
remote: true, method: :delete,
class: ['icon', 'reaction-button', 'reacted'],
@@ -64,7 +64,7 @@ module ReactionsHelper
def reaction_button_not_reacted(object, count, tooltip)
reaction_button_wrapper object do
link_to(
- sprite_icon('thumb-up', count),
+ sprite_icon('thumb-up', count.nonzero?),
reactions_path(object_type: object.class.name, object_id: object),
remote: true, method: :post,
class: 'icon reaction-button',
@@ -76,7 +76,7 @@ module ReactionsHelper
def reaction_button_readonly(object, count, tooltip)
reaction_button_wrapper object do
tag.span(class: 'icon reaction-button readonly', title: tooltip) do
- sprite_icon('thumb-up', count)
+ sprite_icon('thumb-up', count.nonzero?)
end
end
end