Class: Thredded::UserTopicReadState
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Thredded::UserTopicReadState
show all
- Includes:
- UserTopicReadStateCommon
- Defined in:
- app/models/thredded/user_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
41
42
43
44
|
# File 'app/models/thredded/user_topic_read_state.rb', line 41
def read_on_first_post!(user, post)
create!(user: user, postable_id: post.postable_id, messageboard_id: post.messageboard_id,
read_at: post.created_at, read_posts_count: 1, unread_posts_count: 0)
end
|
.topic_class ⇒ Object
17
18
19
|
# File 'app/models/thredded/user_topic_read_state.rb', line 17
def topic_class
Thredded::Topic
end
|
.touch!(user_id, post, overwrite_newer: false) ⇒ Object
28
29
30
31
32
33
34
35
36
37
|
# File 'app/models/thredded/user_topic_read_state.rb', line 28
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.messageboard_id = post.messageboard_id
state.read_at = post.created_at
state.update!(state.calculate_post_counts)
rescue ActiveRecord::RecordNotUnique
retry
end
|
.visible_posts_scope(user) ⇒ Object
21
22
23
|
# File 'app/models/thredded/user_topic_read_state.rb', line 21
def visible_posts_scope(user)
Thredded::Post.moderation_state_visible_to_user(user)
end
|