mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-26 06:11:15 +00:00
Add error toast for 413 content too large response on image uploads (#1675)
Co-authored-by: SleeplessOne1917 <abias1122@gmail.com>
This commit is contained in:
parent
0764b75dc2
commit
bca438b2c6
4 changed files with 10 additions and 0 deletions
|
@ -84,6 +84,8 @@ export class ImageUploadForm extends Component<
|
||||||
if (res.state === "success") {
|
if (res.state === "success") {
|
||||||
if (res.data.msg === "ok") {
|
if (res.data.msg === "ok") {
|
||||||
i.props.onUpload(res.data.url as string);
|
i.props.onUpload(res.data.url as string);
|
||||||
|
} else if (res.data.msg === "too_large") {
|
||||||
|
toast(I18NextService.i18n.t("upload_too_large"), "danger");
|
||||||
} else {
|
} else {
|
||||||
toast(JSON.stringify(res), "danger");
|
toast(JSON.stringify(res), "danger");
|
||||||
}
|
}
|
||||||
|
|
|
@ -443,6 +443,10 @@ export class MarkdownTextArea extends Component<
|
||||||
const textarea: any = document.getElementById(i.id);
|
const textarea: any = document.getElementById(i.id);
|
||||||
autosize.update(textarea);
|
autosize.update(textarea);
|
||||||
pictrsDeleteToast(image.name, res.data.delete_url as string);
|
pictrsDeleteToast(image.name, res.data.delete_url as string);
|
||||||
|
} else if (res.data.msg === "too_large") {
|
||||||
|
toast(I18NextService.i18n.t("upload_too_large"), "danger");
|
||||||
|
i.setState({ imageUploadStatus: undefined });
|
||||||
|
throw JSON.stringify(res.data);
|
||||||
} else {
|
} else {
|
||||||
throw JSON.stringify(res.data);
|
throw JSON.stringify(res.data);
|
||||||
}
|
}
|
||||||
|
|
|
@ -508,6 +508,8 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
|
||||||
{ form: form, index: index, overrideValue: res.data.url as string },
|
{ form: form, index: index, overrideValue: res.data.url as string },
|
||||||
event
|
event
|
||||||
);
|
);
|
||||||
|
} else if (res.data.msg === "too_large") {
|
||||||
|
toast(I18NextService.i18n.t("upload_too_large"), "danger");
|
||||||
} else {
|
} else {
|
||||||
toast(JSON.stringify(res), "danger");
|
toast(JSON.stringify(res), "danger");
|
||||||
}
|
}
|
||||||
|
|
|
@ -187,6 +187,8 @@ function handleImageUpload(i: PostForm, event: any) {
|
||||||
imageLoading: false,
|
imageLoading: false,
|
||||||
imageDeleteUrl: res.data.delete_url as string,
|
imageDeleteUrl: res.data.delete_url as string,
|
||||||
});
|
});
|
||||||
|
} else if (res.data.msg === "too_large") {
|
||||||
|
toast(I18NextService.i18n.t("upload_too_large"), "danger");
|
||||||
} else {
|
} else {
|
||||||
toast(JSON.stringify(res), "danger");
|
toast(JSON.stringify(res), "danger");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue