Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
uploads: Fix duplicate drag-and-drop uploads during message editing.
Sayam Samal65be62e4cb5b
diff --git a/web/src/message_edit.js b/web/src/message_edit.jsindex cbfa3000a6c..c10554f8af3 100644--- a/web/src/message_edit.js+++ b/web/src/message_edit.js@@ -793,9 +793,15 @@ export function end_inline_topic_edit($row) {function remove_uploads_from_row(row_id) {const uploads_for_row = upload.upload_objects_by_message_edit_row.get(row_id);+ if (!uploads_for_row) {+ return;+ }// We need to cancel all uploads, reset their progress,// and clear the files upon ending the edit.- uploads_for_row?.cancelAll();+ upload.deactivate_upload(uploads_for_row, {+ mode: "edit",+ row: row_id,+ });// Since we removed all the uploads from the row, we should// now remove the corresponding upload object from the store.upload.upload_objects_by_message_edit_row.delete(row_id);diff --git a/web/src/upload.js b/web/src/upload.jsindex 5c55489da93..6db89fb6691 100644--- a/web/src/upload.js+++ b/web/src/upload.js@@ -437,6 +437,18 @@ export function setup_upload(config) {return uppy;}+export function deactivate_upload(uppy, config) {+ // Remove event listeners added for handling uploads.+ $(get_item("file_input_identifier", config)).off("change");+ get_item("banner_container", config).off("click");+ get_item("drag_drop_container", config).off("dragover dragenter drop paste");++ // Uninstall all plugins and close down the Uppy instance.+ // Also runs uppy.cancelAll() before uninstalling - which+ // cancels all uploads, resets progress and removes all files.+ uppy.close();+}+export function initialize() {compose_upload_object = setup_upload({mode: "compose",