current stand

This commit is contained in:
Myzel394 2022-11-16 20:11:22 +01:00
parent 91e7b43a5b
commit e426dc8cd9
2 changed files with 30 additions and 4 deletions

View File

@ -70,9 +70,32 @@ export default function AliasNotesForm({id, notes, queryKey}: AliasNotesFormProp
), ),
}) })
const {mutateAsync} = useMutation<Alias, AxiosError, UpdateAliasData>( const {mutateAsync} = useMutation<
values => updateAlias(id, values), 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 => { onSuccess: async newAlias => {
;(newAlias as any as DecryptedAlias).notes = decryptAliasNotes( ;(newAlias as any as DecryptedAlias).notes = decryptAliasNotes(
newAlias.encryptedNotes, newAlias.encryptedNotes,
@ -85,7 +108,10 @@ export default function AliasNotesForm({id, notes, queryKey}: AliasNotesFormProp
queryClient.setQueryData<DecryptedAlias | Alias>(queryKey, newAlias) queryClient.setQueryData<DecryptedAlias | Alias>(queryKey, newAlias)
}, },
onError: showError, onError: error => {
showError(error)
setIsInEditMode(true)
},
}, },
) )
const initialValues = useMemo( const initialValues = useMemo(

View File

@ -71,7 +71,7 @@ export default function SelectField({
formik.setFieldValue(name, value) formik.setFieldValue(name, value)
}} }}
disabled={formik.sSubmitting} disabled={formik.isSubmitting}
error={Boolean(formik.touched[name] && formik.errors[name])} error={Boolean(formik.touched[name] && formik.errors[name])}
renderValue={value => renderValue={value =>
value === "null" ? ( value === "null" ? (