debian-mirror-gitlab/app/serializers/concerns/user_status_tooltip.rb
2021-03-11 19:13:27 +05:30

29 lines
626 B
Ruby

# frozen_string_literal: true
module UserStatusTooltip
extend ActiveSupport::Concern
include ActionView::Helpers::TagHelper
include ActionView::Context
include EmojiHelper
include UsersHelper
included do
expose :status_tooltip_html, if: -> (*) { status_loaded? } do |user|
user_status(user)
end
expose :show_status do |user|
status_loaded? && show_status_emoji?(user.status)
end
expose :availability, if: -> (*) { status_loaded? } do |user|
user.status&.availability
end
private
def status_loaded?
object.association(:status).loaded?
end
end
end