Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable coloring of comments icon for comments created by user itself #515

Merged
Merged
21 changes: 19 additions & 2 deletions app/controllers/commontator/comments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,25 @@ def update_unread_status
return unless medium.released.in?(['all', 'users', 'subscribers'])

relevant_users = medium.teachable.media_scope.users
relevant_users.where(unread_comments: false)
relevant_users.where.not(id: current_user.id)
.where(unread_comments: false)
.update_all(unread_comments: true)
@update_icon = relevant_users.exists?(current_user.id)
Splines marked this conversation as resolved.
Show resolved Hide resolved

# make sure that the thread associated to this comment is marked as read
# by the comment creator (unless some other user posted a comment in it
# that has not yet been read)
@reader = Reader.find_or_create_by(user: current_user,
thread: @commontator_thread)
if unseen_comments?
@update_icon = true
return
end
@reader.update(updated_at: Time.current)
end

def unseen_comments?
@commontator_thread.comments.any? do |c|
c.creator != current_user && c.created_at > @reader.updated_at
end
end
end