Method: Thredded::TopicCommon::ClassMethods#with_read_states

Defined in:
app/models/concerns/thredded/topic_common.rb

#with_read_states(user) ⇒ Array<[TopicCommon, UserTopicReadStateCommon]>

Parameters:

Returns:



73
74
75
76
77
78
79
80
# File 'app/models/concerns/thredded/topic_common.rb', line 73

def with_read_states(user)
  null_read_state = Thredded::NullUserTopicReadState.new
  return current_scope.zip([null_read_state]) if user.thredded_anonymous?
  read_states_by_postable = read_states_by_postable_hash(user)
  current_scope.map do |postable|
    [postable, read_states_by_postable[postable] || null_read_state]
  end
end