Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

upload: Fix TypeScript noUncheckedIndexedAccess errors.

Anders Kaseorg6c0c19addb64
diff --git a/web/src/upload.ts b/web/src/upload.ts
index 11dd402b1fe..cbc98020469 100644
--- a/web/src/upload.ts
+++ b/web/src/upload.ts
@@ -534,7 +534,7 @@ export function initialize(): void {
if (compose_state.composing()) {
// Compose box is open; drop there.
upload_files(compose_upload_object, compose_config, files);
- } else if ($last_drag_drop_edit_container.length !== 0) {
+ } else if ($last_drag_drop_edit_container[0] !== undefined) {
// A message edit box is open; drop there.
const row_id = rows.get_message_id($last_drag_drop_edit_container[0]);
const $drag_drop_container = edit_config(row_id).drag_drop_container();
diff --git a/web/tests/upload.test.js b/web/tests/upload.test.js
index 5bab39ee5eb..cd15479fd16 100644
--- a/web/tests/upload.test.js
+++ b/web/tests/upload.test.js
@@ -754,7 +754,7 @@ test("main_file_drop_edit_mode", ({override, override_rewire}) => {
dropped_row_id = config.row;
upload_files_called = true;
});
- $(".message_edit_form form").last = () => ({length: 1});
+ $(".message_edit_form form").last = () => ({length: 1, [0]: "stub"});
override(rows, "get_message_id", () => 40);
// Edit box which registered the event handler no longer exists.
@@ -776,7 +776,7 @@ test("main_file_drop_edit_mode", ({override, override_rewire}) => {
override(rows, "get_message_id", () => 40);
// Edit box open
- $(".message_edit_form form").last = () => ({length: 1});
+ $(".message_edit_form form").last = () => ({length: 1, [0]: "stub"});
drop_handler(drop_event);
assert.equal(upload_files_called, true);
assert.equal(dropped_row_id, 40);