fix 1695 by not updating ancestors on zap (#1766)
* fix 1695 by not updating ancestors on zap * update ancestors but only onPaid
This commit is contained in:
parent
6efa782c11
commit
18445b1dc1
|
@ -181,7 +181,7 @@ export default function ItemAct ({ onClose, item, act = 'TIP', step, children, a
|
|||
|
||||
function modifyActCache (cache, { result, invoice }) {
|
||||
if (!result) return
|
||||
const { id, sats, path, act } = result
|
||||
const { id, sats, act } = result
|
||||
cache.modify({
|
||||
id: `Item:${id}`,
|
||||
fields: {
|
||||
|
@ -211,7 +211,13 @@ function modifyActCache (cache, { result, invoice }) {
|
|||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// doing this onPaid fixes issue #1695 because optimistically updating all ancestors
|
||||
// conflicts with the writeQuery on navigation from SSR
|
||||
function updateAncestors (cache, { result, invoice }) {
|
||||
if (!result) return
|
||||
const { id, sats, act, path } = result
|
||||
if (act === 'TIP') {
|
||||
// update all ancestors
|
||||
path.split('.').forEach(aId => {
|
||||
|
@ -259,6 +265,7 @@ export function useAct ({ query = ACT_MUTATION, ...options } = {}) {
|
|||
onPaid: (cache, { data }) => {
|
||||
const response = getPaidActionResult(data)
|
||||
if (!response) return
|
||||
updateAncestors(cache, response)
|
||||
options?.onPaid?.(cache, { data })
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue