make possibly conflicting optimistic cache updates write to each other (#1772)
* make possibly conflicting optimistic cache updates write to each other * always update optimistic caches with cache.modifying items
This commit is contained in:
parent
18445b1dc1
commit
eb22fdab41
@ -17,7 +17,8 @@ export default function BookmarkDropdownItem ({ item: { id, meBookmark } }) {
|
||||
id: `Item:${id}`,
|
||||
fields: {
|
||||
meBookmark: () => bookmarkItem.meBookmark
|
||||
}
|
||||
},
|
||||
optimistic: true
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,8 @@ export default function CommentEdit ({ comment, editThreshold, onSuccess, onCanc
|
||||
text () {
|
||||
return result.text
|
||||
}
|
||||
}
|
||||
},
|
||||
optimistic: true
|
||||
})
|
||||
}
|
||||
},
|
||||
|
@ -30,7 +30,8 @@ export default function Delete ({ itemId, children, onDelete, type = 'post' }) {
|
||||
url: () => deleteItem.url,
|
||||
pollCost: () => deleteItem.pollCost,
|
||||
deletedAt: () => deleteItem.deletedAt
|
||||
}
|
||||
},
|
||||
optimistic: true
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -84,7 +84,8 @@ export function OutlawDropdownItem ({ item }) {
|
||||
id: `Item:${item.id}`,
|
||||
fields: {
|
||||
outlawed: () => true
|
||||
}
|
||||
},
|
||||
optimistic: true
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -209,7 +209,8 @@ function modifyActCache (cache, { result, invoice }) {
|
||||
}
|
||||
return existingBoost
|
||||
}
|
||||
}
|
||||
},
|
||||
optimistic: true
|
||||
})
|
||||
}
|
||||
|
||||
@ -228,7 +229,8 @@ function updateAncestors (cache, { result, invoice }) {
|
||||
commentSats (existingCommentSats = 0) {
|
||||
return existingCommentSats + sats
|
||||
}
|
||||
}
|
||||
},
|
||||
optimistic: true
|
||||
})
|
||||
})
|
||||
}
|
||||
|
@ -22,7 +22,8 @@ export const payBountyCacheMods = {
|
||||
bountyPaidTo (existingPaidTo = []) {
|
||||
return [...(existingPaidTo || []), Number(id)]
|
||||
}
|
||||
}
|
||||
},
|
||||
optimistic: true
|
||||
})
|
||||
},
|
||||
onPayError: (e, cache, { data }) => {
|
||||
@ -36,7 +37,8 @@ export const payBountyCacheMods = {
|
||||
bountyPaidTo (existingPaidTo = []) {
|
||||
return (existingPaidTo || []).filter(i => i !== Number(id))
|
||||
}
|
||||
}
|
||||
},
|
||||
optimistic: true
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -123,7 +123,8 @@ export function usePollVote ({ query = POLL_VOTE, itemId }) {
|
||||
poll.count += 1
|
||||
return poll
|
||||
}
|
||||
}
|
||||
},
|
||||
optimistic: true
|
||||
})
|
||||
cache.modify({
|
||||
id: `PollOption:${id}`,
|
||||
@ -131,7 +132,8 @@ export function usePollVote ({ query = POLL_VOTE, itemId }) {
|
||||
count (existingCount) {
|
||||
return existingCount + 1
|
||||
}
|
||||
}
|
||||
},
|
||||
optimistic: true
|
||||
})
|
||||
}
|
||||
|
||||
@ -154,7 +156,8 @@ export function usePollVote ({ query = POLL_VOTE, itemId }) {
|
||||
poll.count -= 1
|
||||
return poll
|
||||
}
|
||||
}
|
||||
},
|
||||
optimistic: true
|
||||
})
|
||||
cache.modify({
|
||||
id: `PollOption:${id}`,
|
||||
@ -162,7 +165,8 @@ export function usePollVote ({ query = POLL_VOTE, itemId }) {
|
||||
count (existingCount) {
|
||||
return existingCount - 1
|
||||
}
|
||||
}
|
||||
},
|
||||
optimistic: true
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,8 @@ export default forwardRef(function Reply ({
|
||||
})
|
||||
return [newCommentRef, ...existingCommentRefs]
|
||||
}
|
||||
}
|
||||
},
|
||||
optimistic: true
|
||||
})
|
||||
|
||||
// no lag for itemRepetition
|
||||
@ -102,7 +103,8 @@ export default forwardRef(function Reply ({
|
||||
ncomments (existingNComments = 0) {
|
||||
return existingNComments + 1
|
||||
}
|
||||
}
|
||||
},
|
||||
optimistic: true
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -17,7 +17,8 @@ export default function SubscribeDropdownItem ({ item: { id, meSubscription } })
|
||||
id: `Item:${id}`,
|
||||
fields: {
|
||||
meSubscription: () => subscribeItem.meSubscription
|
||||
}
|
||||
},
|
||||
optimistic: true
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -118,7 +118,8 @@ export function useRetryCreateItem ({ id }) {
|
||||
`,
|
||||
data: { bolt11: response.invoice.bolt11 }
|
||||
})
|
||||
}
|
||||
},
|
||||
optimistic: true
|
||||
})
|
||||
paidActionCacheMods?.update?.(cache, { data })
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user