debian-mirror-gitlab/app/serializers/concerns/user_status_tooltip.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

30 lines
621 B
Ruby
Raw Normal View History

2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
module UserStatusTooltip
extend ActiveSupport::Concern
include ActionView::Helpers::TagHelper
2020-03-13 15:44:24 +05:30
include ActionView::Context
2018-11-18 11:00:15 +05:30
include EmojiHelper
include UsersHelper
included do
2021-02-22 17:27:13 +05:30
expose :status_tooltip_html, if: -> (*) { status_loaded? } do |user|
user_status(user)
end
expose :show_status do |user|
2022-08-27 11:52:29 +05:30
status_loaded? && !!user.status&.customized?
2021-02-22 17:27:13 +05:30
end
2018-11-18 11:00:15 +05:30
2021-03-11 19:13:27 +05:30
expose :availability, if: -> (*) { status_loaded? } do |user|
user.status&.availability
end
2021-02-22 17:27:13 +05:30
private
2018-11-18 11:00:15 +05:30
2021-02-22 17:27:13 +05:30
def status_loaded?
object.association(:status).loaded?
2018-11-18 11:00:15 +05:30
end
end
end