From 6c0c19addb6428060b18a624bb1d557c2d801d70 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Thu, 30 May 2024 10:08:00 -0700 Subject: [PATCH] upload: Fix TypeScript noUncheckedIndexedAccess errors. Signed-off-by: Anders Kaseorg --- web/src/upload.ts | 2 +- web/tests/upload.test.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/web/src/upload.ts b/web/src/upload.ts index 11dd402b1f..cbc9802046 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 5bab39ee5e..cd15479fd1 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);