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|
|
|
|
|
status_loaded? && show_status_emoji?(user.status)
|
|
|
|
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
|