2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2013-03-06 15:17:07 -05:00
|
|
|
# Helps us determine whether a topic should be displayed as pinned or not,
|
|
|
|
# taking into account anonymous users and users who have dismissed it
|
|
|
|
class PinnedCheck
|
|
|
|
|
2014-04-09 20:56:56 -04:00
|
|
|
def self.unpinned?(topic, topic_user = nil)
|
|
|
|
topic.pinned_at &&
|
|
|
|
topic_user &&
|
|
|
|
topic_user.cleared_pinned_at &&
|
|
|
|
topic_user.cleared_pinned_at > topic.pinned_at
|
2013-03-06 15:17:07 -05:00
|
|
|
end
|
|
|
|
|
2014-04-09 20:56:56 -04:00
|
|
|
def self.pinned?(topic, topic_user = nil)
|
|
|
|
!!topic.pinned_at &&
|
|
|
|
!unpinned?(topic, topic_user)
|
2013-03-06 15:17:07 -05:00
|
|
|
end
|
|
|
|
|
2014-04-09 20:56:56 -04:00
|
|
|
end
|