Added "Entity too large" failure toast.
authorAdam Dullage <redacted>
Mon, 5 Feb 2024 13:20:02 +0000 (13:20 +0000)
committerAdam Dullage <redacted>
Mon, 5 Feb 2024 13:20:02 +0000 (13:20 +0000)
client/components/NoteViewerEditor.vue

index 182eeb8c90965466beb4ad4d9b751818cb3d4c31..e62467b775f48f1a749104d3a2a686ac6a7779b8 100644 (file)
@@ -264,7 +264,6 @@ export default {
             response.data.lastModified,
             response.data.content
           );
-          // EventBus.$emit("updateDocumentTitle", parent.currentNote.title);
         })
         .catch(function (error) {
           if (error.handled) {
@@ -404,6 +403,18 @@ export default {
       );
     },
 
+    entityTooLargeToast: function (entityName) {
+      this.$bvToast.toast(
+        `This ${entityName.toLowerCase()} is too large. Please try again with a smaller ${entityName.toLowerCase()} or adjust your server configuration.`,
+        {
+          title: `${entityName} Too Large ✘`,
+          variant: "danger",
+          noCloseButton: true,
+          toaster: "b-toaster-bottom-right",
+        }
+      );
+    },
+
     saveNote: function () {
       let parent = this;
       let newContent = this.getEditorContent();
@@ -439,11 +450,10 @@ export default {
           .catch(function (error) {
             if (error.handled) {
               return;
-            } else if (
-              typeof error.response !== "undefined" &&
-              error.response.status == 409
-            ) {
+            } else if (error.response?.status == 409) {
               parent.existingTitleToast();
+            } else if (error.response?.status == 413) {
+              this.entityTooLargeToast("Note");
             } else {
               EventBus.$emit("unhandledServerError");
             }
@@ -635,6 +645,8 @@ export default {
                 toaster: "b-toaster-bottom-right",
               }
             );
+          } else if (error.response?.status == 413) {
+            this.entityTooLargeToast("Attachment");
           } else {
             parent.$bvToast.toast("Failed to upload attachment ✘", {
               variant: "danger",
git clone https://git.99rst.org/PROJECT