mirror of
https://github.com/Myzel394/kleckrelay-website.git
synced 2025-06-19 07:55:25 +02:00
current stand
This commit is contained in:
parent
91e7b43a5b
commit
e426dc8cd9
@ -70,9 +70,32 @@ export default function AliasNotesForm({id, notes, queryKey}: AliasNotesFormProp
|
||||
),
|
||||
})
|
||||
|
||||
const {mutateAsync} = useMutation<Alias, AxiosError, UpdateAliasData>(
|
||||
values => updateAlias(id, values),
|
||||
const {mutateAsync} = useMutation<
|
||||
Alias,
|
||||
AxiosError,
|
||||
AliasNote,
|
||||
{previousAlias?: DecryptedAlias}
|
||||
>(
|
||||
values => {
|
||||
updateAlias(id, values)
|
||||
},
|
||||
{
|
||||
onMutate: async values => {
|
||||
await queryClient.cancelQueries(queryKey)
|
||||
|
||||
const previousAlias = queryClient.getQueryData<DecryptedAlias>(queryKey)
|
||||
|
||||
if (previousAlias) {
|
||||
;(previousAlias as any as DecryptedAlias).notes = decryptAliasNotes(
|
||||
(previousAlias as any as Alias).encryptedNotes,
|
||||
_decryptUsingMasterPassword,
|
||||
)
|
||||
}
|
||||
|
||||
return {
|
||||
previousAlias,
|
||||
}
|
||||
},
|
||||
onSuccess: async newAlias => {
|
||||
;(newAlias as any as DecryptedAlias).notes = decryptAliasNotes(
|
||||
newAlias.encryptedNotes,
|
||||
@ -85,7 +108,10 @@ export default function AliasNotesForm({id, notes, queryKey}: AliasNotesFormProp
|
||||
|
||||
queryClient.setQueryData<DecryptedAlias | Alias>(queryKey, newAlias)
|
||||
},
|
||||
onError: showError,
|
||||
onError: error => {
|
||||
showError(error)
|
||||
setIsInEditMode(true)
|
||||
},
|
||||
},
|
||||
)
|
||||
const initialValues = useMemo(
|
||||
|
@ -71,7 +71,7 @@ export default function SelectField({
|
||||
|
||||
formik.setFieldValue(name, value)
|
||||
}}
|
||||
disabled={formik.sSubmitting}
|
||||
disabled={formik.isSubmitting}
|
||||
error={Boolean(formik.touched[name] && formik.errors[name])}
|
||||
renderValue={value =>
|
||||
value === "null" ? (
|
||||
|
Loading…
x
Reference in New Issue
Block a user