diff --git a/components/comment.js b/components/comment.js
index a258e3a4..03819801 100644
--- a/components/comment.js
+++ b/components/comment.js
@@ -186,7 +186,7 @@ export default function Comment ({
{!noReply &&
}
{children}
diff --git a/components/item-full.js b/components/item-full.js
index 30ce000f..562d9e1a 100644
--- a/components/item-full.js
+++ b/components/item-full.js
@@ -31,7 +31,7 @@ function BioItem ({ item, handleClick }) {
>edit bio
}
-
+
>
)
}
@@ -89,7 +89,7 @@ function TopLevelItem ({ item, noReply, ...props }) {
{item.text &&
}
{item.url &&
}
{item.poll &&
}
- {!noReply &&
}
+ {!noReply &&
}
)
}
diff --git a/components/reply.js b/components/reply.js
index 9eee8796..4239e698 100644
--- a/components/reply.js
+++ b/components/reply.js
@@ -21,10 +21,11 @@ export function ReplyOnAnotherPage ({ parentId }) {
)
}
-export default function Reply ({ parentId, onSuccess, replyOpen }) {
+export default function Reply ({ item, onSuccess, replyOpen }) {
const [reply, setReply] = useState(replyOpen)
const me = useMe()
const [hasImgLink, setHasImgLink] = useState()
+ const parentId = item.id
useEffect(() => {
setReply(replyOpen || !!localStorage.getItem('reply-' + parentId + '-' + 'text'))
@@ -52,12 +53,21 @@ export default function Reply ({ parentId, onSuccess, replyOpen }) {
fragmentName: 'CommentsRecursive'
})
return [newCommentRef, ...existingCommentRefs]
- },
- ncomments (existingNComments = 0) {
- return existingNComments + 1
}
}
})
+
+ // update all ancestors
+ item.path.split('.').forEach(id => {
+ cache.modify({
+ id: `Item:${id}`,
+ fields: {
+ ncomments (existingNComments = 0) {
+ return existingNComments + 1
+ }
+ }
+ })
+ })
}
}
)
diff --git a/components/upvote.js b/components/upvote.js
index 70ecfb2a..f1c44404 100644
--- a/components/upvote.js
+++ b/components/upvote.js
@@ -135,6 +135,19 @@ export default function UpVote ({ item, className }) {
}
}
})
+
+ // update all ancestors
+ item.path.split('.').forEach(id => {
+ if (Number(id) === Number(item.id)) return
+ cache.modify({
+ id: `Item:${id}`,
+ fields: {
+ commentSats (existingCommentSats = 0) {
+ return existingCommentSats + sats
+ }
+ }
+ })
+ })
}
}
)