update item repetition optimistically

This commit is contained in:
k00b 2024-09-25 18:02:40 -05:00
parent 68f7e4111b
commit 3f49c93ecb
1 changed files with 12 additions and 0 deletions

View File

@ -14,6 +14,7 @@ import { useRoot } from './root'
import { commentSubTreeRootId } from '@/lib/item'
import { CREATE_COMMENT } from '@/fragments/paidAction'
import useItemSubmit from './use-item-submit'
import gql from 'graphql-tag'
export function ReplyOnAnotherPage ({ item }) {
const rootId = commentSubTreeRootId(item)
@ -80,6 +81,17 @@ export default forwardRef(function Reply ({
}
})
// no lag for itemRepetition
if (!item.mine) {
cache.updateQuery({
query: gql`{ itemRepetition(parentId: "${parentId}") }`
}, data => {
return {
itemRepetition: (data?.itemRepetition || 0) + 1
}
})
}
const ancestors = item.path.split('.')
// update all ancestors