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

Thread read notifications #417

Merged
merged 8 commits into from Jan 31, 2018

Conversation

Projects
None yet
3 participants
@hmadison
Contributor

hmadison commented Oct 8, 2017

Resolves #218.

Adds a new page which shows all of the immediate child comments of stories/comments you have posted. This should help keep discussion on stories which fall off the front page from dying off.


Unread replies shown in navigation:

screen shot 2017-10-08 at 10 10 52 am

The page itself:

screen shot 2017-10-08 at 10 10 56 am

@hmadison hmadison changed the title from Hm/thread read notifications to Thread read notifications Oct 8, 2017

@pushcx

Thanks for taking a first pass at this, it'll help keep discussions going.

I think there's enough going on here that replies need their own controller, and it should present sub-navigation to pages listing unread replies, all replies, comment replies, and story replies. Additionally, it shouldn't be necessary to click 'mark read', they should be considered read if they've been rendered to page (which can be accomplished easiest by not paginating the unread page).

It also needs to be possible to unsubscribe from seeing replies to a story or comment. I will admit to having posted one or two stories on topics I'm not interested in reading the comments on. 😃

@hmadison

This comment has been minimized.

Show comment
Hide comment
@hmadison

hmadison Oct 21, 2017

Contributor

I've made the changes you requested.


The new replies page:

screen shot 2017-10-21 at 1 33 16 pm

Contributor

hmadison commented Oct 21, 2017

I've made the changes you requested.


The new replies page:

screen shot 2017-10-21 at 1 33 16 pm

@pushcx

This looks really good. I'm going to play with it a bit locally to see the UI and such, but wanted to post the small style nits and questions so you can see them immediately. I'm looking forward to merging this.

Show outdated Hide outdated app/controllers/comments_controller.rb
@@ -4,7 +4,7 @@ class CommentsController < ApplicationController
# for rss feeds, load the user's tag filters if a token is passed
before_action :find_user_from_rss_token, :only => [ :index ]
before_action :require_logged_in_user_or_400,
:only => [ :create, :preview, :upvote, :downvote, :unvote ]
:only => [ :create, :preview, :upvote, :downvote, :unvote]

This comment has been minimized.

@pushcx

pushcx Jan 29, 2018

Member

Whitespace typo.

@pushcx

pushcx Jan 29, 2018

Member

Whitespace typo.

@@ -0,0 +1,3 @@
class ApplicationRecord < ActiveRecord::Base

This comment has been minimized.

@pushcx

pushcx Jan 29, 2018

Member

How about a name like ApplicationView to make it clear what this is for and why it's not used on other models?

@pushcx

pushcx Jan 29, 2018

Member

How about a name like ApplicationView to make it clear what this is for and why it's not used on other models?

This comment has been minimized.

@hmadison

hmadison Jan 29, 2018

Contributor

See rails/rails#22567. New rails 5 projects generate this by default.

@hmadison

hmadison Jan 29, 2018

Contributor

See rails/rails#22567. New rails 5 projects generate this by default.

Show outdated Hide outdated app/models/read_ribbon.rb
belongs_to :user
belongs_to :story
class << self

This comment has been minimized.

@pushcx

pushcx Jan 29, 2018

Member

Codebase style is to do def self.hide_replies_for rather than the nested class definition and I'd like to stick to it.

@pushcx

pushcx Jan 29, 2018

Member

Codebase style is to do def self.hide_replies_for rather than the nested class definition and I'd like to stick to it.

@@ -8,6 +8,7 @@ class StoriesController < ApplicationController
before_action :find_user_story, :only => [ :destroy, :edit, :undelete,
:update ]
before_action :find_story!, :only => [ :suggest, :submit_suggestions ]
around_action :track_story_reads, only: [ :show ], if: -> { @user.present? }

This comment has been minimized.

@pushcx

pushcx Jan 29, 2018

Member

Really nice use of around_action and after_action in these controllers.

@pushcx

pushcx Jan 29, 2018

Member

Really nice use of around_action and after_action in these controllers.

@@ -0,0 +1,43 @@
<div class="box wide">
<div class="legend right">
<%= link_to_filter('unread') %> |

This comment has been minimized.

@pushcx

pushcx Jan 29, 2018

Member

Real nice helper to keep this tidy and clear.

@pushcx

pushcx Jan 29, 2018

Member

Real nice helper to keep this tidy and clear.

Show outdated Hide outdated app/views/replies/show.html.erb
<%= render "comments/comment",
comment: reply.comment,
show_story: true,
is_unread: reply.is_unread %>

This comment has been minimized.

@pushcx

pushcx Jan 29, 2018

Member

Add show_tree_lines: false

@pushcx

pushcx Jan 29, 2018

Member

Add show_tree_lines: false

Show outdated Hide outdated app/views/replies/show.html.erb
<% end %>
</ol>
<% @filter != 'unread' && if @replies.count > RepliesController::REPLIES_PER_PAGE %>

This comment has been minimized.

@pushcx

pushcx Jan 29, 2018

Member

Please move the if left of the first conditional.

@pushcx

pushcx Jan 29, 2018

Member

Please move the if left of the first conditional.

@@ -56,7 +56,8 @@
:show_story => (comment.story_id != @story.id),
:show_tree_lines => true,
:was_merged => (comment.story_id != @story.id),
:children => children %>
:children => children,
:is_unread => is_unread?(comment) %>

This comment has been minimized.

@pushcx

pushcx Jan 29, 2018

Member

indent

@pushcx

pushcx Jan 29, 2018

Member

indent

@@ -0,0 +1,3 @@
Scenic.configure do |config|
config.database = Scenic::Adapters::Mysql.new

This comment has been minimized.

@pushcx

pushcx Jan 29, 2018

Member

Can we avoid saying MySQL here and pull it from Rails.config or database.yml? I'm thinking of barnacles, the other sister sites using postgresql, and my daydream of moving Lobsters to pg. I saw that Gemfile gets scenic-mysql added; anyone using pg now is already forked there, just hoping to minimize their edit points.

@pushcx

pushcx Jan 29, 2018

Member

Can we avoid saying MySQL here and pull it from Rails.config or database.yml? I'm thinking of barnacles, the other sister sites using postgresql, and my daydream of moving Lobsters to pg. I saw that Gemfile gets scenic-mysql added; anyone using pg now is already forked there, just hoping to minimize their edit points.

Show outdated Hide outdated db/migrate/20171018192044_create_read_ribbons.rb
class CreateReadRibbons < ActiveRecord::Migration[5.1]
def change
create_table :read_ribbons do |t|
# t.belongs_to :user, foreign_key: true

This comment has been minimized.

@pushcx

pushcx Jan 29, 2018

Member

Why comment this out to do in a second migration? And can the create_view migration get folded in to this one as well?

@pushcx

pushcx Jan 29, 2018

Member

Why comment this out to do in a second migration? And can the create_view migration get folded in to this one as well?

comments parent_comments ON parent_comments.id = comments.parent_comment_id
WHERE
read_ribbons.is_following = 1
AND comments.user_id != read_ribbons.user_id

This comment has been minimized.

@pushcx

pushcx Jan 30, 2018

Member

I slept on this PR and it occurred to me: please add AND (comments.upvotes - comments.downvotes) < 0 AND (parent_comments.upvotes - parent_comments.downvotes) < 0 (we can memoize a score column if this becomes a performance issue). I want this reply tracking because it's going to help sustain really good conversations, I don't want it to sustain flame wars.

@pushcx

pushcx Jan 30, 2018

Member

I slept on this PR and it occurred to me: please add AND (comments.upvotes - comments.downvotes) < 0 AND (parent_comments.upvotes - parent_comments.downvotes) < 0 (we can memoize a score column if this becomes a performance issue). I want this reply tracking because it's going to help sustain really good conversations, I don't want it to sustain flame wars.

This comment has been minimized.

@hmadison

hmadison Jan 31, 2018

Contributor

Added below.

@hmadison

hmadison Jan 31, 2018

Contributor

Added below.

@pushcx

pushcx approved these changes Jan 31, 2018

@pushcx

This comment has been minimized.

Show comment
Hide comment
@pushcx

pushcx Jan 31, 2018

Member

Thanks for these last tweaks and all the little style conformance nitpicking.

I just hit 'approve' on the review, but will hold on hitting merge and pushing until tomorrow morning so I can make an announce post as @talklittle suggested.

Member

pushcx commented Jan 31, 2018

Thanks for these last tweaks and all the little style conformance nitpicking.

I just hit 'approve' on the review, but will hold on hitting merge and pushing until tomorrow morning so I can make an announce post as @talklittle suggested.

@ribbon = ReadRibbon.where(user_id: @user.id, story_id: story.id).first_or_create
yield
@ribbon.updated_at = Time.now
@ribbon.save

This comment has been minimized.

@metaskills

metaskills Jan 31, 2018

Maybe use @ribbon.touch here?

@metaskills

metaskills Jan 31, 2018

Maybe use @ribbon.touch here?

This comment has been minimized.

@pushcx

pushcx Jan 31, 2018

Member

Good idiom to use, thanks. I don't know what @hmadison's schedule is this morning, so I'm going to merge and then commit that myself.

@pushcx

pushcx Jan 31, 2018

Member

Good idiom to use, thanks. I don't know what @hmadison's schedule is this morning, so I'm going to merge and then commit that myself.

@pushcx pushcx merged commit dd42cca into lobsters:master Jan 31, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment