diff --git a/web/src/compose_actions.js b/web/src/compose_actions.js index 333b514d88..526a666ee3 100644 --- a/web/src/compose_actions.js +++ b/web/src/compose_actions.js @@ -332,7 +332,7 @@ export function cancel() { clear_box(); compose_banner.clear_message_sent_banners(); call_hooks(compose_cancel_hooks); - compose_state.set_message_type(false); + compose_state.set_message_type(undefined); compose_pm_pill.clear(); $(document).trigger("compose_canceled.zulip"); } diff --git a/web/src/compose_state.ts b/web/src/compose_state.ts index abfea4f0fa..ef0d433051 100644 --- a/web/src/compose_state.ts +++ b/web/src/compose_state.ts @@ -5,9 +5,9 @@ import {$t} from "./i18n"; import * as people from "./people"; import * as sub_store from "./sub_store"; -let message_type: "stream" | "private" | false = false; +let message_type: "stream" | "private" | undefined; let recipient_edited_manually = false; -let last_focused_compose_type_input: HTMLInputElement | false = false; // an HTML input element or false-y +let last_focused_compose_type_input: HTMLInputElement | undefined; // We use this variable to keep track of whether user has viewed the topic resolved // banner for the current compose session, for a narrow. This prevents the banner @@ -29,15 +29,15 @@ export function set_last_focused_compose_type_input(element: HTMLInputElement): last_focused_compose_type_input = element; } -export function get_last_focused_compose_type_input(): HTMLInputElement | false { +export function get_last_focused_compose_type_input(): HTMLInputElement | undefined { return last_focused_compose_type_input; } -export function set_message_type(msg_type: "stream" | "private" | false): void { +export function set_message_type(msg_type: "stream" | "private" | undefined): void { message_type = msg_type; } -export function get_message_type(): "stream" | "private" | false { +export function get_message_type(): "stream" | "private" | undefined { return message_type; } diff --git a/web/tests/compose.test.js b/web/tests/compose.test.js index 743a52e586..be61661f60 100644 --- a/web/tests/compose.test.js +++ b/web/tests/compose.test.js @@ -564,7 +564,7 @@ test_ui("update_fade", ({override, override_rewire}) => { update_narrow_to_recipient_visibility_called = true; }); - compose_state.set_message_type(false); + compose_state.set_message_type(undefined); compose_recipient.update_on_recipient_change(); assert.ok(!set_focused_recipient_checked); assert.ok(!update_all_called); diff --git a/web/tests/compose_actions.test.js b/web/tests/compose_actions.test.js index 9cc5baa5ec..8ad03ff367 100644 --- a/web/tests/compose_actions.test.js +++ b/web/tests/compose_actions.test.js @@ -100,14 +100,14 @@ function test(label, f) { $(".new_message_textarea").css = noop; people.init(); - compose_state.set_message_type(false); + compose_state.set_message_type(undefined); f(helpers); }); } test("initial_state", () => { assert.equal(compose_state.composing(), false); - assert.equal(compose_state.get_message_type(), false); + assert.equal(compose_state.get_message_type(), undefined); assert.equal(compose_state.has_message_content(), false); }); @@ -466,7 +466,7 @@ test("focus_in_empty_compose", () => { $("textarea#compose-textarea").val(""); assert.ok(compose_state.focus_in_empty_compose()); - compose_state.set_message_type(false); + compose_state.set_message_type(undefined); assert.ok(!compose_state.focus_in_empty_compose()); $("textarea#compose-textarea").val("foo"); diff --git a/web/tests/drafts.test.js b/web/tests/drafts.test.js index a795033348..3d1d7c5148 100644 --- a/web/tests/drafts.test.js +++ b/web/tests/drafts.test.js @@ -244,7 +244,7 @@ test("remove_old_drafts", () => { }); test("update_draft", ({override, override_rewire}) => { - compose_state.set_message_type(false); + compose_state.set_message_type(undefined); let draft_id = drafts.update_draft(); assert.equal(draft_id, undefined); diff --git a/web/tests/narrow.test.js b/web/tests/narrow.test.js index 2f96d80da9..2859d6f631 100644 --- a/web/tests/narrow.test.js +++ b/web/tests/narrow.test.js @@ -660,7 +660,7 @@ run_test("narrow_to_compose_target errors", ({disallow_rewire}) => { disallow_rewire(narrow, "activate"); // No-op when not composing. - compose_state.set_message_type(false); + compose_state.set_message_type(undefined); narrow.to_compose_target(); // No-op when empty stream.