stacker.news/components/comment.module.css
soxa f0e3516cf0
Refactor live comments and comment injection (#2462)
* Fix duplicate comment on pessimistic creation

- comment creation checks for comment's ID existence in cache
- invoice.confirmedAt included in useCanEdit deps for anons live comments

* switch to some as sets are not worth it

* only check for duplicates if a pessimistic payment method has been used

* default to empty array

* add comment about side-effects

* record ownership of an item to avoid injecting it via live comments

* trigger check only if the incoming comment is ours, cleanup

* correct conditions, correct comments, light cleanup

* fix: add defensive condition to ownership recorder, better name

* refactor: unified comment injection logic with deduplication, useCommentsView hook; revert sessionStorage-based fix

* adjust live comments naming around the codebase

* listen for hmac presence for anon edits

* always return the injected comment createdAt to bump live comments

* refactor: improve live comments hook readability

- latest comment createdAt persistence helper
- preserveScroll returns the returning value of the callback
- compact conditional logic
- refresh code comments
- refresh naming
- group constants
- reorder imports

* flat comment injection, fetch flat comments instead of the entire subtree that would've been deduplicated anyway, cleanup

* always align new comment fragment to the comments query structure

* generic useCommentsView hook

* update comment counts if live injecting into fragments without comments field

* fix: pass parentId, if a comment has a top level parent it always has the comments field

* fix: update CommentsViewAt only if we actually injected a comment into cache

* correct injectComment result usage

* pass markViewedAt to further centralize side effects, remove live from Item server typedefs

* fix: don't update counts for ancestors that are already up to date, update commentsViewedAt per batch not per comment

* port: fix coalesce, useCommentsView hook and outline changes

* update hmac field in cache on paid invoice, hmac as useCanEdit effect dependency

* comments and light cleanup, update useCommentsView

* efficient hasComments logic for live comments, establish a gql fragment

* fix: typo on topLevel evaluation

* limit extra evaluations to live comments scenarios

* update comments

* support live comments ncomments increments for anon view tracking
2025-09-07 16:04:34 -05:00

169 lines
2.5 KiB
CSS

.item {
align-items: flex-start;
margin-bottom: 0 !important;
padding-top: 0 !important;
}
.upvote {
margin-top: 9px;
padding-right: 0.2rem;
}
.pin {
fill: #a5a5a5;
margin-left: .2rem;
margin-right: .3rem;
flex-shrink: 0;
}
.dontLike {
fill: #a5a5a5;
margin-right: 2px;
margin-top: 9px;
cursor: pointer;
}
.text {
margin-top: .1rem;
padding-right: 15px;
}
.edit {
display: inline-block;
cursor: pointer;
}
.op {
margin-top: -1px;
vertical-align: text-top;
}
.collapsed .hunk {
margin-bottom: .5rem;
}
.collapsed .text,
.collapsed .children {
display: none;
}
.collapsed .upvote, .collapsed .dontLike {
visibility: hidden;
height: 0;
}
.collapser {
cursor: pointer;
fill: var(--theme-grey);
width: 45px;
margin-left: auto;
user-select: none;
}
.children {
margin-top: 0;
margin-left: 15px;
}
.comments {
margin-left: -15px;
}
@media screen and (min-width: 768px) {
.comments {
margin-left: 0px;
}
.children {
margin-left: 25px;
}
}
.skeleton .hunk {
width: 100%;
}
.skeleton .text {
height: 80px;
border-radius: .4rem;
margin-right: 15px;
}
.skeleton .reply {
width: 45px;
height: 10px;
border-radius: .2rem;
}
.replyPadder {
padding: .25rem 0;
padding-bottom: .5rem;
}
.replyContainer {
display: flex;
justify-content: flex-start;
align-items: center;
}
.comment {
border-radius: .4rem;
padding-top: .5rem;
padding-left: .7rem;
background-color: var(--theme-commentBg);
}
.bountyIcon {
margin-left: 5px;
margin-right: 5px;
}
.hunk {
margin-bottom: 0;
margin-top: 0.15rem;
}
.comment:not(:last-of-type) {
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
}
.comment:not(:first-of-type) {
padding-top: 0;
border-top-left-radius: 0;
border-top-right-radius: 0;
}
.comment:has(.comment) + .comment{
padding-top: .5rem;
}
.liveComment {
animation: fadeIn 0.5s ease-out;
}
@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
}
.commentNavigator {
display: flex;
align-items: center;
vertical-align: middle;
gap: 0.2rem;
padding-bottom: 0.2rem;
justify-content: center;
cursor: pointer;
/* prevent double tap from zooming */
touch-action: manipulation;
}
.newCommentDot {
width: 12px;
height: 12px;
border-radius: 50%;
background-color: #007cbe;
}