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