Skip to content

Commit ee18316

Browse files
committed
fix regression: topLevel comments not showing
1 parent 0c58834 commit ee18316

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

components/comments.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ export default function Comments ({
7575
// fetch new comments that arrived after the lastCommentAt, and update the item.newComments field in cache
7676
useLiveComments(parentId, lastCommentAt || parentCreatedAt, router.query.sort, setHasNewComments)
7777
console.log('hasNewComments', hasNewComments)
78+
console.log('sort', router.query.sort)
7879
const hasNewNotes = useHasNewNotes()
7980

8081
const pins = useMemo(() => comments?.filter(({ position }) => !!position).sort((a, b) => a.position - b.position), [comments])
@@ -101,7 +102,7 @@ export default function Comments ({
101102
/>
102103
: null}
103104
{newComments?.length > 0 && (
104-
<ShowNewComments comments={comments} newComments={newComments} itemId={parentId} sort={router.query.sort} setHasNewComments={setHasNewComments} />
105+
<ShowNewComments topLevel comments={comments} newComments={newComments} itemId={parentId} sort={router.query.sort} setHasNewComments={setHasNewComments} />
105106
)}
106107
{pins.map(item => (
107108
<Fragment key={item.id}>

components/show-new-comments.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,12 @@ function collectAllNewComments (item) {
7777
}
7878

7979
// TODO: Fix bug where new comments out of depth are not shown
80-
export function ShowNewComments ({ sort, comments, newComments = [], itemId, item, setHasNewComments }) {
80+
export function ShowNewComments ({ topLevel, sort, comments, itemId, item, setHasNewComments, newComments = [] }) {
8181
const client = useApolloClient()
8282

83-
const topLevel = !!sort
8483
// if item is provided, we're showing all new comments for a thread,
8584
// otherwise we're showing new comments for a comment
86-
const isThread = item.path.split('.').length === 2
85+
const isThread = !topLevel && item?.path.split('.').length === 2
8786
const allNewComments = useMemo(() => {
8887
if (isThread) {
8988
return collectAllNewComments(item)

0 commit comments

Comments
 (0)