refactor: Pass only stream id, not name, to compose_actions.start().

As part of the process of moving from stream names to ids, we now only
pass the stream id in compose args to `compose_actions.start()`.

For when we still need the stream name, and have access to the compose
args, we compute it from the id exactly where needed, to localise the
instances of stream names.
This commit is contained in:
N-Shar-ma
2024-01-07 03:47:15 +05:30
committed by Tim Abbott
parent d8044a1b07
commit f99635d582
3 changed files with 8 additions and 5 deletions

View File

@@ -198,11 +198,9 @@ export function restore_message(draft) {
let compose_args;
if (draft.type === "stream") {
const stream_name = stream_data.get_stream_name_from_id(draft.stream_id);
compose_args = {
type: "stream",
stream_id: draft.stream_id,
stream_name,
topic: draft.topic,
content: draft.content,
};

View File

@@ -29,7 +29,10 @@ function restore_draft(draft_id) {
if (draft.stream_id !== undefined && draft.topic !== "") {
narrow.activate(
[
{operator: "stream", operand: compose_args.stream_name},
{
operator: "stream",
operand: stream_data.get_stream_name_from_id(compose_args.stream_id),
},
{operator: "topic", operand: compose_args.topic},
],
{trigger: "restore draft"},

View File

@@ -21,7 +21,10 @@ function narrow_via_edit_scheduled_message(compose_args) {
if (compose_args.type === "stream") {
narrow.activate(
[
{operator: "stream", operand: compose_args.stream},
{
operator: "stream",
operand: stream_data.get_stream_name_from_id(compose_args.stream_id),
},
{operator: "topic", operand: compose_args.topic},
],
{trigger: "edit scheduled message"},
@@ -39,7 +42,6 @@ export function open_scheduled_message_in_compose(scheduled_msg, should_narrow_t
compose_args = {
type: "stream",
stream_id: scheduled_msg.to,
stream: stream_data.get_stream_name_from_id(scheduled_msg.to),
topic: scheduled_msg.topic,
content: scheduled_msg.content,
};