From fd4f41a14e22c0162d15f754af49846a4cd796f7 Mon Sep 17 00:00:00 2001 From: mbliznikova Date: Tue, 30 Jan 2024 19:19:25 +0000 Subject: [PATCH] Added an informative UI error message for attempt to create a mixed media album --- .../assets/js/components/ComposeModal.vue | 36 ++++++++++++++----- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/resources/assets/js/components/ComposeModal.vue b/resources/assets/js/components/ComposeModal.vue index 2c4e3ba42..e4ae59c87 100644 --- a/resources/assets/js/components/ComposeModal.vue +++ b/resources/assets/js/components/ComposeModal.vue @@ -1094,6 +1094,16 @@ export default { return `${parseFloat((bytes / Math.pow(1024, quotient)).toFixed(dec))} ${units[quotient]}` }, + defineErrorMessage(errObject) { + if (errObject.response) { + let msg = errObject.response.data.message ? errObject.response.data.message : 'An unexpected error occured.'; + } + else { + let msg = errObject.message; + } + return swal('Oops, something went wrong!', msg, 'error'); + }, + fetchProfile() { let tags = { public: 'Public', @@ -1395,15 +1405,23 @@ export default { location.href = res.data; } }).catch(err => { - if(err.response) { - let msg = err.response.data.message ? err.response.data.message : 'An unexpected error occured.' - swal('Oops, something went wrong!', msg, 'error'); - } else { - swal('Oops, something went wrong!', err.message, 'error'); - } - }); - return; - break; + switch(err.response.status) { + case 400: + if (err.response.data.error == "Must contain a single photo or video or multiple photos.") { + swal("Wrong types of mixed media", "The album must contain a single photo or video or multiple photos.", 'error'); + } + else { + this.defineErrorMessage(err); + } + break; + + default: + this.defineErrorMessage(err); + break; + } + }); + return; + break; case 'delete' : this.ids = [];