@@ -181,7 +181,7 @@ export default function ItemAct ({ onClose, item, act = 'TIP', step, children, a
181181
182182function modifyActCache ( cache , { result, invoice } ) {
183183 if ( ! result ) return
184- const { id, sats, path , act } = result
184+ const { id, sats, act } = result
185185 cache . modify ( {
186186 id : `Item:${ id } ` ,
187187 fields : {
@@ -209,9 +209,16 @@ function modifyActCache (cache, { result, invoice }) {
209209 }
210210 return existingBoost
211211 }
212- }
212+ } ,
213+ optimistic : true
213214 } )
215+ }
214216
217+ // doing this onPaid fixes issue #1695 because optimistically updating all ancestors
218+ // conflicts with the writeQuery on navigation from SSR
219+ function updateAncestors ( cache , { result, invoice } ) {
220+ if ( ! result ) return
221+ const { id, sats, act, path } = result
215222 if ( act === 'TIP' ) {
216223 // update all ancestors
217224 path . split ( '.' ) . forEach ( aId => {
@@ -222,7 +229,8 @@ function modifyActCache (cache, { result, invoice }) {
222229 commentSats ( existingCommentSats = 0 ) {
223230 return existingCommentSats + sats
224231 }
225- }
232+ } ,
233+ optimistic : true
226234 } )
227235 } )
228236 }
@@ -259,6 +267,7 @@ export function useAct ({ query = ACT_MUTATION, ...options } = {}) {
259267 onPaid : ( cache , { data } ) => {
260268 const response = getPaidActionResult ( data )
261269 if ( ! response ) return
270+ updateAncestors ( cache , response )
262271 options ?. onPaid ?. ( cache , { data } )
263272 }
264273 } )
0 commit comments