compose: Migrate `empty_topic_placeholder` to `compose_state`.

This makes it so that `drafts.js` now no longer imports `compose.js`.
This commit is contained in:
N-Shar-ma 2023-10-03 02:26:07 +05:30 committed by Tim Abbott
parent e87b9955c9
commit 681180ee86
6 changed files with 13 additions and 12 deletions

View File

@ -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

View File

@ -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);

View File

@ -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 = {

View File

@ -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");

View File

@ -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;

View File

@ -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",