-
+
{
+ const viewedAt = commentsViewedAt(item)
+ if (viewedAt) {
+ e.preventDefault()
+ router.push(
+ `/items/${item.id}?commentsViewedAt=${viewedAt}`,
+ `/items/${item.id}`)
+ }
+ }} ref={titleRef} className={`${styles.title} text-reset me-2`}
+ >
{item.searchTitle ?
: item.title}
{item.pollCost &&
}
{item.bounty > 0 &&
diff --git a/lib/new-comments.js b/lib/new-comments.js
index 1742879a..20ae8dd4 100644
--- a/lib/new-comments.js
+++ b/lib/new-comments.js
@@ -14,13 +14,17 @@ export function commentsViewedAfterComment (rootId, createdAt) {
window.localStorage.setItem(`${COMMENTS_NUM_PREFIX}:${rootId}`, existingRootComments + 1)
}
+export function commentsViewedAt (item) {
+ return window.localStorage.getItem(`${COMMENTS_VIEW_PREFIX}:${item.id}`)
+}
+
export function newComments (item) {
if (!item.parentId) {
- const commentsViewedAt = window.localStorage.getItem(`${COMMENTS_VIEW_PREFIX}:${item.id}`)
- const commentsViewNum = window.localStorage.getItem(`${COMMENTS_NUM_PREFIX}:${item.id}`)
+ const viewedAt = commentsViewedAt(item)
+ const viewNum = window.localStorage.getItem(`${COMMENTS_NUM_PREFIX}:${item.id}`)
- if (commentsViewedAt && commentsViewNum) {
- return commentsViewedAt < new Date(item.lastCommentAt).getTime() || commentsViewNum < item.ncomments
+ if (viewedAt && viewNum) {
+ return viewedAt < new Date(item.lastCommentAt).getTime() || viewNum < item.ncomments
}
}
diff --git a/styles/globals.scss b/styles/globals.scss
index 2e3221d7..8b50fa52 100644
--- a/styles/globals.scss
+++ b/styles/globals.scss
@@ -688,6 +688,10 @@ div[contenteditable]:focus,
animation: outline 3s linear 1;
}
+.outline-new-comment {
+ box-shadow: inset 0 0 1px 1px rgba(0, 123, 190, 0.35);
+}
+
@keyframes spin {
0% {
transform: rotate(0deg);