Skip to content

Commit

Permalink
fix: replace avatar image on cancel bug
Browse files Browse the repository at this point in the history
  • Loading branch information
dmijatovic committed Jan 12, 2023
1 parent 55fe25c commit 2678e67
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 40 deletions.
24 changes: 4 additions & 20 deletions frontend/components/projects/edit/team/TeamMemberModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,26 +89,10 @@ export default function TeamMemberModal({open, onCancel, onSubmit, member, pos}:

async function replaceImage(avatar_b64:string, avatar_mime_type:string) {
if (formData.id && formData.avatar_id) {
// remove refrence to avatar first
const patch = await patchTeamMember({
member: {
id: formData.id,
avatar_id: null
},
token
})
// debugger
if (patch.status !== 200) {
showErrorMessage('Failed to remove image')
return
}
// then try to remove avatar from db
// without waiting for result
const del = await deleteImage({
id: formData.avatar_id,
token
})
// remove id in the form too
// mark old image for deletion
// we will remove it on Save
setRemoveAvatar(formData.avatar_id)
// and remove id in the form too
setValue('avatar_id', null)
}
// write new logo to logo_b64
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,26 +88,10 @@ export default function EditContributorModal({open, onCancel, onSubmit, contribu

async function replaceImage(avatar_b64:string, avatar_mime_type:string) {
if (formData.id && formData.avatar_id) {
// remove refrence to avatar first
const patch = await patchContributor({
contributor: {
id: formData.id,
avatar_id: null
},
token
})
// debugger
if (patch.status !== 200) {
showErrorMessage('Failed to remove image')
return
}
// then try to remove avatar from db
// without waiting for result
const del = await deleteImage({
id: formData.avatar_id,
token
})
// remove id in the form too
// mark old image for deletion
// we will remove it on Save
setRemoveAvatar(formData.avatar_id)
// and remove id in the form too
setValue('avatar_id', null)
}
// write new logo to logo_b64
Expand Down

0 comments on commit 2678e67

Please sign in to comment.