diff --git a/web/src/compose.js b/web/src/compose.js index da8552efe9..34391e1653 100644 --- a/web/src/compose.js +++ b/web/src/compose.js @@ -152,15 +152,11 @@ export function abort_video_callbacks(edit_message_id = "") { } } -export function empty_topic_placeholder() { - return $t({defaultMessage: "(no topic)"}); -} - export function create_message_object() { // Topics are optional, and we provide a placeholder if one isn't given. let topic = compose_state.topic(); if (topic === "") { - topic = empty_topic_placeholder(); + topic = compose_state.empty_topic_placeholder(); } // Changes here must also be kept in sync with echo.try_deliver_locally diff --git a/web/src/compose_state.js b/web/src/compose_state.js index bb80a28a66..b417570e81 100644 --- a/web/src/compose_state.js +++ b/web/src/compose_state.js @@ -2,6 +2,7 @@ import $ from "jquery"; import * as compose_pm_pill from "./compose_pm_pill"; import * as compose_recipient from "./compose_recipient"; +import {$t} from "./i18n"; import * as sub_store from "./sub_store"; let message_type = false; // 'stream', 'private', or false-y @@ -100,6 +101,10 @@ export function set_compose_recipient_id(recipient_id) { // TODO: Break out setter and getter into their own functions. export const topic = get_or_set("stream_message_recipient_topic"); +export function empty_topic_placeholder() { + return $t({defaultMessage: "(no topic)"}); +} + // We can't trim leading whitespace in `compose_textarea` because // of the indented syntax for multi-line code blocks. export const message_content = get_or_set("compose-textarea", true); diff --git a/web/src/drafts.js b/web/src/drafts.js index 50fd714542..82c1c79ff3 100644 --- a/web/src/drafts.js +++ b/web/src/drafts.js @@ -9,7 +9,6 @@ import render_draft_table_body from "../templates/draft_table_body.hbs"; import * as blueslip from "./blueslip"; import * as browser_history from "./browser_history"; -import * as compose from "./compose"; import * as compose_actions from "./compose_actions"; import * as compose_state from "./compose_state"; import * as confirm_dialog from "./confirm_dialog"; @@ -347,7 +346,7 @@ export function format_draft(draft) { invite_only = sub.invite_only; is_web_public = sub.is_web_public; } - const draft_topic = draft.topic || compose.empty_topic_placeholder(); + const draft_topic = draft.topic || compose_state.empty_topic_placeholder(); const draft_stream_color = stream_data.get_color(draft.stream_id); formatted = { diff --git a/web/src/message_edit.js b/web/src/message_edit.js index e372a95646..e028591c8b 100644 --- a/web/src/message_edit.js +++ b/web/src/message_edit.js @@ -13,6 +13,7 @@ import * as channel from "./channel"; import * as compose from "./compose"; import * as compose_actions from "./compose_actions"; import * as compose_banner from "./compose_banner"; +import * as compose_state from "./compose_state"; import * as compose_ui from "./compose_ui"; import * as compose_validate from "./compose_validate"; import * as composebox_typeahead from "./composebox_typeahead"; @@ -756,7 +757,7 @@ export function start_inline_topic_edit($recipient_row) { const msg_id = rows.id_for_recipient_row($recipient_row); const message = message_lists.current.get(msg_id); let topic = message.topic; - if (topic === compose.empty_topic_placeholder()) { + if (topic === compose_state.empty_topic_placeholder()) { topic = ""; } const $inline_topic_edit_input = $form.find(".inline_topic_edit"); diff --git a/web/src/message_list_view.js b/web/src/message_list_view.js index 35ae1225fd..7b4efa369a 100644 --- a/web/src/message_list_view.js +++ b/web/src/message_list_view.js @@ -11,8 +11,8 @@ import render_single_message from "../templates/single_message.hbs"; import * as activity from "./activity"; import * as blueslip from "./blueslip"; -import * as compose from "./compose"; import * as compose_fade from "./compose_fade"; +import * as compose_state from "./compose_state"; import * as condense from "./condense"; import * as hash_util from "./hash_util"; import {$t} from "./i18n"; @@ -176,7 +176,7 @@ function set_topic_edit_properties(group, message) { // Messages with no topics should always have an edit icon visible // to encourage updating them. Admins can also edit any topic. - if (message.topic === compose.empty_topic_placeholder()) { + if (message.topic === compose_state.empty_topic_placeholder()) { group.always_visible_topic_edit = true; } else { group.on_hover_topic_edit = true; diff --git a/web/tests/popover_menus_data.test.js b/web/tests/popover_menus_data.test.js index 4fe23df620..7c6e9a3c38 100644 --- a/web/tests/popover_menus_data.test.js +++ b/web/tests/popover_menus_data.test.js @@ -11,7 +11,7 @@ const {MessageList} = zrequire("message_list"); const message_lists = zrequire("message_lists"); const popover_menus_data = zrequire("popover_menus_data"); const people = zrequire("people"); -const compose = zrequire("compose"); +const compose_state = zrequire("compose_state"); const noop = function () {}; @@ -242,7 +242,7 @@ test("not_my_message_view_source_and_move", () => { type: "stream", unread: false, collapsed: false, - topic: compose.empty_topic_placeholder(), + topic: compose_state.empty_topic_placeholder(), edit_history: [ { prev_content: "Previous content",