Fix localStorage cleared because error were swallowed
This commit is contained in:
parent
38fddcf283
commit
73aa0d2d44
@ -90,7 +90,7 @@ export function BountyForm ({
|
|||||||
onSubmit={
|
onSubmit={
|
||||||
handleSubmit ||
|
handleSubmit ||
|
||||||
(async ({ boost, bounty, cost, ...values }) => {
|
(async ({ boost, bounty, cost, ...values }) => {
|
||||||
await invoiceableUpsertBounty(cost, boost, bounty, values)
|
return invoiceableUpsertBounty(cost, boost, bounty, values)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
storageKeyPrefix={item ? undefined : 'bounty'}
|
storageKeyPrefix={item ? undefined : 'bounty'}
|
||||||
|
@ -79,7 +79,7 @@ export function DiscussionForm ({
|
|||||||
}}
|
}}
|
||||||
schema={schema}
|
schema={schema}
|
||||||
onSubmit={handleSubmit || (async ({ boost, cost, ...values }) => {
|
onSubmit={handleSubmit || (async ({ boost, cost, ...values }) => {
|
||||||
await invoiceableUpsertDiscussion(cost, boost, values)
|
return invoiceableUpsertDiscussion(cost, boost, values)
|
||||||
})}
|
})}
|
||||||
storageKeyPrefix={item ? undefined : 'discussion'}
|
storageKeyPrefix={item ? undefined : 'discussion'}
|
||||||
>
|
>
|
||||||
|
@ -470,8 +470,8 @@ export function Form ({
|
|||||||
initialTouched={validateImmediately && initial}
|
initialTouched={validateImmediately && initial}
|
||||||
validateOnBlur={false}
|
validateOnBlur={false}
|
||||||
onSubmit={async (values, ...args) =>
|
onSubmit={async (values, ...args) =>
|
||||||
onSubmit && onSubmit(values, ...args).then(() => {
|
onSubmit && onSubmit(values, ...args).then((options) => {
|
||||||
if (!storageKeyPrefix) return
|
if (!storageKeyPrefix || options?.keepLocalStorage) return
|
||||||
Object.keys(values).forEach(v => {
|
Object.keys(values).forEach(v => {
|
||||||
window.localStorage.removeItem(storageKeyPrefix + '-' + v)
|
window.localStorage.removeItem(storageKeyPrefix + '-' + v)
|
||||||
if (Array.isArray(values[v])) {
|
if (Array.isArray(values[v])) {
|
||||||
|
@ -225,13 +225,16 @@ export const useInvoiceable = (fn, options = defaultOptions) => {
|
|||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
return
|
return { keepLocalStorage: true }
|
||||||
}
|
}
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setFnArgs(args)
|
setFnArgs(args)
|
||||||
return createInvoice({ variables: { amount } })
|
await createInvoice({ variables: { amount } })
|
||||||
|
// tell onSubmit handler that we want to keep local storage
|
||||||
|
// even though the submit handler was "successful"
|
||||||
|
return { keepLocalStorage: true }
|
||||||
}, [fn, setFnArgs, createInvoice])
|
}, [fn, setFnArgs, createInvoice])
|
||||||
|
|
||||||
return actionFn
|
return actionFn
|
||||||
|
@ -76,7 +76,7 @@ export default function ItemAct ({ onClose, itemId, act, strike }) {
|
|||||||
}}
|
}}
|
||||||
schema={amountSchema}
|
schema={amountSchema}
|
||||||
onSubmit={async ({ amount }) => {
|
onSubmit={async ({ amount }) => {
|
||||||
await invoiceableAct(amount)
|
return invoiceableAct(amount)
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Input
|
<Input
|
||||||
|
@ -102,7 +102,7 @@ export default function JobForm ({ item, sub }) {
|
|||||||
schema={jobSchema}
|
schema={jobSchema}
|
||||||
storageKeyPrefix={storageKeyPrefix}
|
storageKeyPrefix={storageKeyPrefix}
|
||||||
onSubmit={(async ({ maxBid, stop, start, ...values }) => {
|
onSubmit={(async ({ maxBid, stop, start, ...values }) => {
|
||||||
await invoiceableUpsertJob(1000, maxBid, stop, start, values)
|
return invoiceableUpsertJob(1000, maxBid, stop, start, values)
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
<div className='form-group'>
|
<div className='form-group'>
|
||||||
|
@ -119,7 +119,7 @@ export function LinkForm ({ item, sub, editThreshold, children }) {
|
|||||||
}}
|
}}
|
||||||
schema={schema}
|
schema={schema}
|
||||||
onSubmit={async ({ boost, title, cost, ...values }) => {
|
onSubmit={async ({ boost, title, cost, ...values }) => {
|
||||||
await invoiceableUpsertLink(cost, boost, title, values)
|
return invoiceableUpsertLink(cost, boost, title, values)
|
||||||
}}
|
}}
|
||||||
storageKeyPrefix={item ? undefined : 'link'}
|
storageKeyPrefix={item ? undefined : 'link'}
|
||||||
>
|
>
|
||||||
|
@ -70,7 +70,7 @@ export function PollForm ({ item, sub, editThreshold, children }) {
|
|||||||
}}
|
}}
|
||||||
schema={schema}
|
schema={schema}
|
||||||
onSubmit={async ({ boost, title, options, cost, ...values }) => {
|
onSubmit={async ({ boost, title, options, cost, ...values }) => {
|
||||||
await invoiceableUpsertPoll(cost, boost, title, options, values)
|
return invoiceableUpsertPoll(cost, boost, title, options, values)
|
||||||
}}
|
}}
|
||||||
storageKeyPrefix={item ? undefined : 'poll'}
|
storageKeyPrefix={item ? undefined : 'poll'}
|
||||||
>
|
>
|
||||||
|
@ -130,7 +130,7 @@ export default function Reply ({ item, onSuccess, replyOpen, children, placehold
|
|||||||
}}
|
}}
|
||||||
schema={commentSchema}
|
schema={commentSchema}
|
||||||
onSubmit={async ({ cost, ...values }, { resetForm }) => {
|
onSubmit={async ({ cost, ...values }, { resetForm }) => {
|
||||||
await invoiceableCreateComment(cost, values, parentId, resetForm)
|
return invoiceableCreateComment(cost, values, parentId, resetForm)
|
||||||
}}
|
}}
|
||||||
storageKeyPrefix={'reply-' + parentId}
|
storageKeyPrefix={'reply-' + parentId}
|
||||||
>
|
>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user