Skip to content

Commit 535afb8

Browse files
committed
favicon-new-comment, fix favicon showing also when there aren't new comments
1 parent d1abb2e commit 535afb8

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

components/comments.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,20 +70,19 @@ export default function Comments ({
7070
parentId, pinned, bio, parentCreatedAt,
7171
commentSats, comments, commentsCursor, fetchMoreComments, ncomments, newComments, lastCommentAt, ...props
7272
}) {
73-
const [hasNewComments, setHasNewComments] = useState(false)
7473
const router = useRouter()
74+
const [hasNewComments, setHasNewComments] = useState(false)
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)
77-
console.log('hasNewComments', hasNewComments)
78-
console.log('sort', router.query.sort)
77+
// xxx
7978
const hasNewNotes = useHasNewNotes()
8079

8180
const pins = useMemo(() => comments?.filter(({ position }) => !!position).sort((a, b) => a.position - b.position), [comments])
8281

8382
return (
8483
<>
8584
<Head>
86-
<link rel='shortcut icon' href={hasNewComments ? '/favicon.png' : hasNewNotes ? '/favicon-notify.png' : '/favicon.png'} />
85+
<link rel='shortcut icon' href={hasNewComments ? '/favicon-new-comment.png' : hasNewNotes ? '/favicon-notify.png' : '/favicon.png'} />
8786
</Head>
8887
{comments?.length > 0
8988
? <CommentsHeader

components/use-live-comments.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default function useLiveComments (rootId, after, sort, setHasNewComments)
2323
})
2424

2525
useEffect(() => {
26-
if (!data?.newComments) return
26+
if (!data?.newComments?.comments?.length) return
2727

2828
// sometimes new comments can arrive as orphans because their parent might not be in the cache yet
2929
// queue them up, retry until the parent shows up.

public/favicon-new-comment.png

10.2 KB
Loading

0 commit comments

Comments
 (0)