From 3f49c93ecb3fc442ff2299a6fa29cf9b6011d12b Mon Sep 17 00:00:00 2001 From: k00b Date: Wed, 25 Sep 2024 18:02:40 -0500 Subject: [PATCH] update item repetition optimistically --- components/reply.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/components/reply.js b/components/reply.js index eb837b97..8ef1ee53 100644 --- a/components/reply.js +++ b/components/reply.js @@ -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