]> Untitled Git - lemmy-ui.git/blobdiff - src/shared/utils.ts
Merge branch 'LemmyNet:main' into multiple-images-upload
[lemmy-ui.git] / src / shared / utils.ts
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,