Merge branch 'browser_popup'

This commit is contained in:
Dessalines 2022-10-21 14:14:42 -04:00
commit 7f5b260681
4 changed files with 16 additions and 8 deletions

@ -1 +1 @@
Subproject commit ae3132fef13542ab7fc337361bf484183d12d786 Subproject commit 94b9b5debdaa40facf13a852cb096ef0cbd34ad7

View file

@ -386,8 +386,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")}: ${file.name}`,
i18n.t("picture_deleted"), `${i18n.t("picture_deleted")}: ${file.name}`,
`${i18n.t("failed_to_delete_picture")}: ${file.name}`,
deleteUrl deleteUrl
); );
} else { } else {

View file

@ -641,8 +641,9 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
i.state.postForm.url = Some(url); i.state.postForm.url = Some(url);
i.setState({ imageLoading: false }); i.setState({ imageLoading: false });
pictrsDeleteToast( pictrsDeleteToast(
i18n.t("click_to_delete_picture"), `${i18n.t("click_to_delete_picture")}: ${file.name}`,
i18n.t("picture_deleted"), `${i18n.t("picture_deleted")}: ${file.name}`,
`${i18n.t("failed_to_delete_picture")}: ${file.name}`,
deleteUrl deleteUrl
); );
} else { } else {

View file

@ -540,6 +540,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()) {
@ -552,9 +553,14 @@ export function pictrsDeleteToast(
duration: 10000, duration: 10000,
onClick: () => { onClick: () => {
if (toast) { if (toast) {
window.location.replace(deleteUrl); fetch(deleteUrl).then(res => {
alert(deletePictureText);
toast.hideToast(); toast.hideToast();
if (res.ok === true) {
alert(deletePictureText);
} else {
alert(failedDeletePictureText);
}
});
} }
}, },
close: true, close: true,