From: sam365724 <111515092+sam365724@users.noreply.github.com> Date: Fri, 30 Sep 2022 20:36:55 +0000 (+0200) Subject: Merge branch 'LemmyNet:main' into multiple-images-upload X-Git-Url: http://these/git/?a=commitdiff_plain;h=059dfbd3a50c7e9462e963e0101866e79bc0c57b;hp=ef28f3c4d9ffb3adfbc1aa7521187f362487ba31;p=lemmy-ui.git Merge branch 'LemmyNet:main' into multiple-images-upload --- diff --git a/src/shared/components/common/markdown-textarea.tsx b/src/shared/components/common/markdown-textarea.tsx index 69bcd6d..498c262 100644 --- a/src/shared/components/common/markdown-textarea.tsx +++ b/src/shared/components/common/markdown-textarea.tsx @@ -386,8 +386,9 @@ export class MarkdownTextArea extends Component< let textarea: any = document.getElementById(i.id); autosize.update(textarea); pictrsDeleteToast( - i18n.t("click_to_delete_picture"), - i18n.t("picture_deleted"), + i18n.t("click_to_delete_picture").concat('\n(', file.name,')'), + i18n.t("picture_deleted").concat('\n(', file.name,')'), + i18n.t("fail_picture_deleted").concat('\n(', file.name,')'), deleteUrl ); } else { diff --git a/src/shared/utils.ts b/src/shared/utils.ts index d870325..d0b9b4b 100644 --- a/src/shared/utils.ts +++ b/src/shared/utils.ts @@ -540,6 +540,7 @@ export function toast(text: string, background = "success") { export function pictrsDeleteToast( clickToDeleteText: string, deletePictureText: string, + failedDeletePictureText: string, deleteUrl: string ) { if (isBrowser()) { @@ -552,9 +553,16 @@ export function pictrsDeleteToast( duration: 10000, onClick: () => { if (toast) { - window.location.replace(deleteUrl); - alert(deletePictureText); - toast.hideToast(); + fetch(deleteUrl, {}) + .then( res => { + console.log(res) + toast.hideToast(); + if (res.ok === true){ + alert(deletePictureText); + } else{ + alert(failedDeletePictureText); + } + }) } }, close: true,