mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-22 22:49:33 +00:00
Avoid browser warning about leaving page, handle delete image fail and add user filenames to messages.
This commit is contained in:
parent
53e973c140
commit
f2a4ebd92a
|
@ -367,8 +367,9 @@ export class MarkdownTextArea extends Component<
|
||||||
let textarea: any = document.getElementById(i.id);
|
let textarea: any = document.getElementById(i.id);
|
||||||
autosize.update(textarea);
|
autosize.update(textarea);
|
||||||
pictrsDeleteToast(
|
pictrsDeleteToast(
|
||||||
i18n.t("click_to_delete_picture"),
|
i18n.t("click_to_delete_picture").concat('\n(', file.name,')'),
|
||||||
i18n.t("picture_deleted"),
|
i18n.t("picture_deleted").concat('\n(', file.name,')'),
|
||||||
|
i18n.t("fail_picture_deleted").concat('\n(', file.name,')'),
|
||||||
deleteUrl
|
deleteUrl
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -543,6 +543,7 @@ export function toast(text: string, background = "success") {
|
||||||
export function pictrsDeleteToast(
|
export function pictrsDeleteToast(
|
||||||
clickToDeleteText: string,
|
clickToDeleteText: string,
|
||||||
deletePictureText: string,
|
deletePictureText: string,
|
||||||
|
failedDeletePictureText: string,
|
||||||
deleteUrl: string
|
deleteUrl: string
|
||||||
) {
|
) {
|
||||||
if (isBrowser()) {
|
if (isBrowser()) {
|
||||||
|
@ -555,9 +556,16 @@ export function pictrsDeleteToast(
|
||||||
duration: 10000,
|
duration: 10000,
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
if (toast) {
|
if (toast) {
|
||||||
window.location.replace(deleteUrl);
|
fetch(deleteUrl, {})
|
||||||
alert(deletePictureText);
|
.then( res => {
|
||||||
toast.hideToast();
|
console.log(res)
|
||||||
|
toast.hideToast();
|
||||||
|
if (res.ok === true){
|
||||||
|
alert(deletePictureText);
|
||||||
|
} else{
|
||||||
|
alert(failedDeletePictureText);
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
close: true,
|
close: true,
|
||||||
|
|
Loading…
Reference in a new issue