update item repetition optimistically
This commit is contained in:
parent
68f7e4111b
commit
3f49c93ecb
|
@ -14,6 +14,7 @@ import { useRoot } from './root'
|
||||||
import { commentSubTreeRootId } from '@/lib/item'
|
import { commentSubTreeRootId } from '@/lib/item'
|
||||||
import { CREATE_COMMENT } from '@/fragments/paidAction'
|
import { CREATE_COMMENT } from '@/fragments/paidAction'
|
||||||
import useItemSubmit from './use-item-submit'
|
import useItemSubmit from './use-item-submit'
|
||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
export function ReplyOnAnotherPage ({ item }) {
|
export function ReplyOnAnotherPage ({ item }) {
|
||||||
const rootId = commentSubTreeRootId(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('.')
|
const ancestors = item.path.split('.')
|
||||||
|
|
||||||
// update all ancestors
|
// update all ancestors
|
||||||
|
|
Loading…
Reference in New Issue