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