messages: Use stream_id instead of stream name.

This should cause no functional changes.

This is part of a multi-step effort to move away
from using stream names to reference streams, now
that it's impossible for a user to write a message
with an invalid stream name (since switching to
the dropdown).
This commit is contained in:
evykassirer
2023-07-26 13:07:21 -07:00
committed by Tim Abbott
parent 45af8a9406
commit 846b470b99
31 changed files with 154 additions and 108 deletions

View File

@@ -6,6 +6,7 @@ import * as message_lists from "./message_lists";
import * as message_store from "./message_store";
import * as narrow_state from "./narrow_state";
import * as people from "./people";
import * as stream_data from "./stream_data";
export function get_recipient_label(message) {
// TODO: This code path is bit of a type-checking disaster; we mix
@@ -19,8 +20,10 @@ export function get_recipient_label(message) {
// i.e. stream+topic or a single direct message conversation,
// we label the button as replying to the thread.
if (narrow_state.narrowed_to_topic()) {
const stream = narrow_state.stream_sub();
const stream_id = stream?.stream_id;
message = {
stream: narrow_state.stream_name(),
stream_id,
topic: narrow_state.topic(),
};
} else if (narrow_state.pm_ids_string()) {
@@ -44,8 +47,11 @@ export function get_recipient_label(message) {
}
if (message) {
if (message.stream && message.topic) {
return "#" + message.stream + " > " + message.topic;
if (message.stream_id && message.topic) {
const stream = stream_data.get_sub_by_id(message.stream_id);
if (stream) {
return "#" + stream.name + " > " + message.topic;
}
} else if (message.display_reply_to) {
return message.display_reply_to;
}