setLivePolling(true)}
+ style={{ cursor: 'pointer' }}
+ />
+
+
+ )}
comments?.filter(({ position }) => !!position).sort((a, b) => a.position - b.position), [comments])
@@ -75,7 +99,7 @@ export default function Comments ({
{comments?.length > 0
? {
+ pinned={pinned} bio={bio} livePolling={livePolling} setLivePolling={setLivePolling} handleSort={sort => {
const { commentsViewedAt, commentId, ...query } = router.query
delete query.nodata
router.push({
@@ -88,6 +112,9 @@ export default function Comments ({
}}
/>
: null}
+ {newComments?.length > 0 && (
+
+ )}
{pins.map(item => (
diff --git a/components/header.module.css b/components/header.module.css
index 1134e8480..33cf61032 100644
--- a/components/header.module.css
+++ b/components/header.module.css
@@ -109,4 +109,32 @@
padding-top: 1px;
background-color: var(--bs-body-bg);
z-index: 1000;
-}
\ No newline at end of file
+}
+
+.newCommentDot {
+ width: 10px;
+ height: 10px;
+ border-radius: 50%;
+ background-color: var(--bs-primary);
+ animation: pulse 2s infinite;
+}
+
+.newCommentDot.paused {
+ background-color: var(--bs-grey-darkmode);
+ animation: none;
+}
+
+@keyframes pulse {
+ 0% {
+ background-color: #FADA5E;
+ opacity: 0.7;
+ }
+ 50% {
+ background-color: #F6911D;
+ opacity: 1;
+ }
+ 100% {
+ background-color: #FADA5E;
+ opacity: 0.7;
+ }
+}
diff --git a/components/item-full.js b/components/item-full.js
index 72c60b9c6..02621981b 100644
--- a/components/item-full.js
+++ b/components/item-full.js
@@ -182,17 +182,18 @@ export default function ItemFull ({ item, fetchMoreComments, bio, rank, ...props
?
: }
)}
- {item.comments &&
-
-
-
}
+
+
+
>
diff --git a/fragments/comments.js b/fragments/comments.js
index 2fd28d0f1..f7e325c4c 100644
--- a/fragments/comments.js
+++ b/fragments/comments.js
@@ -47,6 +47,7 @@ export const COMMENT_FIELDS = gql`
otsHash
ncomments
nDirectComments
+ newComments @client
imgproxyUrls
rel
apiKey
@@ -116,3 +117,30 @@ export const COMMENTS = gql`
}
}
}`
+
+export const COMMENT_WITH_NEW = gql`
+ ${COMMENT_FIELDS}
+ ${COMMENTS}
+
+ fragment CommentWithNew on Item {
+ ...CommentFields
+ comments {
+ comments {
+ ...CommentsRecursive
+ }
+ }
+ newComments @client
+ }
+`
+
+export const GET_NEW_COMMENTS = gql`
+ ${COMMENTS}
+
+ query GetNewComments($rootId: ID, $after: Date) {
+ newComments(rootId: $rootId, after: $after) {
+ comments {
+ ...CommentsRecursive
+ }
+ }
+ }
+`
diff --git a/fragments/items.js b/fragments/items.js
index 151587a20..95eed0421 100644
--- a/fragments/items.js
+++ b/fragments/items.js
@@ -59,6 +59,7 @@ export const ITEM_FIELDS = gql`
bio
ncomments
nDirectComments
+ newComments @client
commentSats
commentCredits
lastCommentAt
diff --git a/lib/apollo.js b/lib/apollo.js
index 3739ba3fd..dc7b8127b 100644
--- a/lib/apollo.js
+++ b/lib/apollo.js
@@ -313,6 +313,11 @@ function getClient (uri) {
}
}
},
+ newComments: {
+ read (newComments) {
+ return newComments || []
+ }
+ },
meAnonSats: {
read (existingAmount, { readField }) {
if (SSR) return null