2013-03-06 14:17:07 -06: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
|
|
|
|
|
2017-07-27 20:20:09 -05:00
|
|
|
def self.unpinned?(topic, topic_user = nil)
|
2014-04-09 19:56:56 -05:00
|
|
|
topic.pinned_at &&
|
|
|
|
topic_user &&
|
|
|
|
topic_user.cleared_pinned_at &&
|
|
|
|
topic_user.cleared_pinned_at > topic.pinned_at
|
2013-03-06 14:17:07 -06:00
|
|
|
end
|
|
|
|
|
2017-07-27 20:20:09 -05:00
|
|
|
def self.pinned?(topic, topic_user = nil)
|
2014-04-09 19:56:56 -05:00
|
|
|
!!topic.pinned_at &&
|
2017-07-27 20:20:09 -05:00
|
|
|
!unpinned?(topic, topic_user)
|
2013-03-06 14:17:07 -06:00
|
|
|
end
|
|
|
|
|
2014-04-09 19:56:56 -05:00
|
|
|
end
|