Class: Thredded::UserPrivateTopicReadState
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Thredded::UserPrivateTopicReadState
show all
- Includes:
- UserTopicReadStateCommon
- Defined in:
- app/models/thredded/user_private_topic_read_state.rb
Class Method Summary
collapse
#calculate_post_counts, #post_read?, #posts_count, #read?
Class Method Details
.read_on_first_post!(user, post) ⇒ Object
37
38
39
40
|
# File 'app/models/thredded/user_private_topic_read_state.rb', line 37
def read_on_first_post!(user, post)
create!(user: user, postable_id: post.postable_id, read_at: post.created_at, read_posts_count: 1,
unread_posts_count: 0)
end
|
.topic_class ⇒ Object
14
15
16
|
# File 'app/models/thredded/user_private_topic_read_state.rb', line 14
def topic_class
Thredded::PrivateTopic
end
|
.touch!(user_id, post, overwrite_newer: false) ⇒ Object
25
26
27
28
29
30
31
32
33
|
# File 'app/models/thredded/user_private_topic_read_state.rb', line 25
def touch!(user_id, post, overwrite_newer: false)
state = find_or_initialize_by(user_id: user_id, postable_id: post.postable_id)
return if !overwrite_newer && state.read_at? && state.read_at >= post.created_at
state.read_at = post.created_at
state.update!(state.calculate_post_counts)
rescue ActiveRecord::RecordNotUnique
retry
end
|
.visible_posts_scope(_user) ⇒ Object
18
19
20
|
# File 'app/models/thredded/user_private_topic_read_state.rb', line 18
def visible_posts_scope(_user)
Thredded::PrivatePost.all
end
|