2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-08-20 18:52:44 +08:00
discourse/lib/pinned_check.rb

15 lines
478 B
Ruby
Raw Permalink Normal View History

# frozen_string_literal: true
# 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-28 10:20:09 +09: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
end
2017-07-28 10:20:09 +09:00
def self.pinned?(topic, topic_user = nil)
!!topic.pinned_at && !unpinned?(topic, topic_user)
end
end