2018-07-16 12:18:52 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module UserStatusTooltip
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
include ActionView::Helpers::TagHelper
|
2020-01-29 13:08:47 -05:00
|
|
|
include ActionView::Context
|
2018-07-16 12:18:52 -04:00
|
|
|
include EmojiHelper
|
|
|
|
include UsersHelper
|
|
|
|
|
|
|
|
included do
|
2020-11-30 13:09:46 -05:00
|
|
|
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-07-16 12:18:52 -04:00
|
|
|
|
2020-11-30 13:09:46 -05:00
|
|
|
private
|
2018-07-16 12:18:52 -04:00
|
|
|
|
2020-11-30 13:09:46 -05:00
|
|
|
def status_loaded?
|
|
|
|
object.association(:status).loaded?
|
2018-07-16 12:18:52 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|