]> Untitled Git - lemmy-ui.git/commitdiff
Merge branch 'LemmyNet:main' into multiple-images-upload
authorsam365724 <111515092+sam365724@users.noreply.github.com>
Fri, 30 Sep 2022 20:36:55 +0000 (22:36 +0200)
committerGitHub <noreply@github.com>
Fri, 30 Sep 2022 20:36:55 +0000 (22:36 +0200)
src/shared/components/common/markdown-textarea.tsx
src/shared/utils.ts

index 69bcd6df2c009bc592068c2ddeb2b31916422372..498c262579a569eb22cb79e841c1fe6b4c0072b7 100644 (file)
@@ -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 {
index d8703252fcbbda0fbc8917bedbc36fe917b88ecc..d0b9b4bf6de888d1802a9271aef856c0d6f870ad 100644 (file)
@@ -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,