refactor: Extract `RESOLVED_TOPIC_PREFIX` in message_edit.js.

This is a prep commit for #18988. Extracting it here, we
can avoid duplication which helps to avoid future bugs.
This commit is contained in:
akshatdalton 2021-06-26 18:38:33 +00:00 committed by Tim Abbott
parent afe6404167
commit d17e5d080c
2 changed files with 5 additions and 5 deletions

View File

@ -34,6 +34,7 @@ const currently_editing_messages = new Map();
let currently_deleting_messages = [];
let currently_topic_editing_messages = [];
const currently_echoing_messages = new Map();
export const RESOLVED_TOPIC_PREFIX = "✔ ";
// These variables are designed to preserve the user's most recent
// choices when editing a group of messages, to make it convenient to

View File

@ -34,7 +34,6 @@ import * as sub_store from "./sub_store";
import * as subs from "./subs";
import * as unread_ops from "./unread_ops";
const RESOLVED_TOPIC_PREFIX = "✔ ";
// We handle stream popovers and topic popovers in this
// module. Both are popped up from the left sidebar.
let current_stream_sidebar_elem;
@ -276,7 +275,7 @@ function build_topic_popover(opts) {
topic_muted,
can_move_topic,
is_realm_admin: page_params.is_admin,
topic_is_resolved: topic_name.startsWith(RESOLVED_TOPIC_PREFIX),
topic_is_resolved: topic_name.startsWith(message_edit.RESOLVED_TOPIC_PREFIX),
color: sub.color,
has_starred_messages,
});
@ -685,7 +684,7 @@ export function register_topic_handlers() {
function mark_topic_as_resolved(stream_id, topic_name) {
const request = {
propagate_mode: "change_all",
topic: RESOLVED_TOPIC_PREFIX + topic_name,
topic: message_edit.RESOLVED_TOPIC_PREFIX + topic_name,
send_notification_to_old_thread: false,
send_notification_to_new_thread: true,
};
@ -700,7 +699,7 @@ export function register_topic_handlers() {
function mark_topic_as_unresolved(stream_id, topic_name) {
const request = {
propagate_mode: "change_all",
topic: _.trimStart(topic_name, RESOLVED_TOPIC_PREFIX),
topic: _.trimStart(topic_name, message_edit.RESOLVED_TOPIC_PREFIX),
send_notification_to_old_thread: false,
send_notification_to_new_thread: true,
};
@ -716,7 +715,7 @@ export function register_topic_handlers() {
const topic_row = $(e.currentTarget);
const stream_id = Number.parseInt(topic_row.attr("data-stream-id"), 10);
const topic_name = topic_row.attr("data-topic-name");
if (topic_name.startsWith(RESOLVED_TOPIC_PREFIX)) {
if (topic_name.startsWith(message_edit.RESOLVED_TOPIC_PREFIX)) {
mark_topic_as_unresolved(stream_id, topic_name);
} else {
mark_topic_as_resolved(stream_id, topic_name);