-
-
Notifications
You must be signed in to change notification settings - Fork 131
Live updates to comment threads #2115
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
base: master
Are you sure you want to change the base?
Conversation
…new comment; cleanup: resolvers, logs
…omments are there
…bility change, light cleanup
… comment injection
… use of constants, general cleanup
…he correct Item query
…fix leak on useEffect because of missing sort atomic apollo cache manipulations; manage top sort not being present in item query cache queue nested comments without a parent, retry on the next poll fix commit messages
… queue comments via state
… dropped comments; ui: show amount of new comments refactor: correct function positioning; cleanup: useless logs
…Comments readFragment fallback to received comment
…ss dedupe on ShowNewComments, count nested ncomments from fresh new comments
The
This count is then propagated to the parent and its ancestors to update their
Items/comments that resides in
A successful fragment that triggered the |
…ates; fix: nested comment structures - new comments indicator for bottomed-out replies - ncomments sync for parent and its ancestors - limited comments fragment for comments that don't have CommentsRecursive - reduce cache complexity by removing useless roundtrips ux: live comments indicator on bottomedOut replies fix: dedupe newComments before displaying ShowNewComments to avoid false positives enhance: store ids of new comments in the cache, instead of carrying full comments that would get discarded anyway hotfix: newComments deduplication ID mismatch, filter null comments from freshNewComments fix: ncomments not updating for all comment levels; refactor: share Reply update ancestors' ncomments function with ShowNewComments cleanup: better naming to indicate the total number of comments including nested comments fix: increment parent comment ncomments cleanup: Items that will have comments will always have a structure where item.comments is true cleanup: reduce code complexity checking the nested comment update result instead of preventively reading the fragment cleanup: avoid double-updating ncomments on parent fix: don't use CommentsRecursive for bottomed-out comments cleanup: better fragment naming; add TODO for absolute bottom comments
This looks good at a glance. One thing I'd be curious to see is how it looks on mobile with deeply nested comments. |
If you're at the stage where you're open to enhancement suggestions. I think it'd be cool to:
|
Of course! These are pretty cool, going to implement them now ^^ There's only a bug left: the deepest comment can't be updated because it lacks It's not a serious problem because you need to go to another page to see its nested comments, but the new comment indicator on |
I recommend starting these enhancements in a new branch. I think this branch can live on its own. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Nested Comments Counted Twice
The totalNComments
calculation double-counts nested comments. The code sums freshNewComments.length
(direct new comments) and comment.ncomments
(nested comments for each new comment). This results in double-counting when freshNewComments
contains both a parent and its new child comment, as the child is counted directly and again as part of the parent's ncomments
total.
components/show-new-comments.js#L25-L30
stacker.news/components/show-new-comments.js
Lines 25 to 30 in 450f7bc
// count the total number of new comments including its nested new comments | |
let totalNComments = freshNewComments.length | |
for (const comment of freshNewComments) { | |
totalNComments += (comment.ncomments || 0) | |
} |
Was this report helpful? Give feedback by reacting with 👍 or 👎
Description
Closes #791
It features a
useLiveComments
hook that incrementally fetches comments newer than the lastcommentAt
timestamp, performing cache updates to thenewComments
field of the parentItem
/Comment
.New comments can be showed with a "X new comments" button that will retrieve fresh copies of the
newComments
from the cache and inject them in the parent'scomment
field.Media
Desktop
Screen.Recording.2025-07-01.at.22.14.53.mp4
Mobile
Untitled.mp4
Additional Context
Live comments features:
Known bugs:
Checklist
Are your changes backwards compatible? Please answer below:
Yes
On a scale of 1-10 how well and how have you QA'd this change and any features it might affect? Please answer below:
6, strong QA but it might benefit from human comment testing
For frontend changes: Tested on mobile, light and dark mode? Please answer below:
Yes
Did you introduce any new environment variables? If so, call them out explicitly here:
n/a