Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
upload: Locally verify file size before uploading the file.
Ivan Toymentsevcd0821084c8c
diff --git a/frontend_tests/node_tests/upload.js b/frontend_tests/node_tests/upload.jsindex c0148f6b016..6126ac938b0 100644--- a/frontend_tests/node_tests/upload.js+++ b/frontend_tests/node_tests/upload.js@@ -476,11 +476,13 @@ test("uppy_events", ({override, override_rewire}) => {files = files.filter((file) => file.id !== file_id);},getState: () => ({- info: {- type: state.type,- details: state.details,- message: state.message,- },+ info: [+ {+ type: state.type,+ details: state.details,+ message: state.message,+ },+ ],}),};};diff --git a/static/js/upload.js b/static/js/upload.jsindex 620f46a9281..4df320488ae 100644--- a/static/js/upload.js+++ b/static/js/upload.js@@ -175,7 +175,13 @@ export function setup_upload(config) {},locale: {strings: {- exceedsSize: $t({defaultMessage: "This file exceeds maximum allowed size of"}),+ exceedsSize: $t(+ {+ defaultMessage:+ "%'{file}' exceeds the maximum file size for attachments ({variable} MB).",+ },+ {variable: `${page_params.max_file_upload_size_mib}`},+ ),failedToUpload: $t({defaultMessage: "Failed to upload %'{file}'"}),},},@@ -279,7 +285,14 @@ export function setup_upload(config) {});uppy.on("info-visible", () => {- const info = uppy.getState().info;+ // Uppy's `info-visible` event is issued after prepending the+ // notice details into the list of event events accessed via+ // uppy.getState().info. Extract the notice details so that we+ // can potentially act on the error.+ //+ // TODO: Ideally, we'd be using the `.error()` hook or+ // something, not parsing error message strings.+ const info = uppy.getState().info[0];if (info.type === "error" && info.message === "No Internet connection") {// server_events already handles the case of no internet.return;