message_list_view: Fix handling of links to deleted streams.

Previously, links to deleted streams would be incorrectly rendered as
stream's name).

Fixes an issue that was reported where after deleting the "general"
stream, the welcome turtle messages might appear as links to
This commit is contained in:
Tim Abbott
2020-01-22 22:42:01 -08:00
parent 2e923a0eb5
commit b45cce61e7

View File

@@ -590,7 +590,13 @@ MessageListView.prototype = {
if (stream_id && !$(this).find(".highlight").length) {
// Display the current name for stream if it is not
// being displayed in search highlight.
$(this).text("#" + stream_data.maybe_get_stream_name(stream_id));
const stream_name = stream_data.maybe_get_stream_name(stream_id);
if (stream_name !== undefined) {
// If the stream has been deleted,
// stream_data.maybe_get_stream_name might return
// undefined. Otherwise, display the current stream name.
$(this).text("#" + stream_name);
}
}
});
@@ -601,7 +607,13 @@ MessageListView.prototype = {
// being displayed in search highlight.
const text = $(this).text();
const topic = text.split('>', 2)[1];
$(this).text("#" + stream_data.maybe_get_stream_name(stream_id) + ' > ' + topic);
const stream_name = stream_data.maybe_get_stream_name(stream_id);
if (stream_name !== undefined) {
// If the stream has been deleted,
// stream_data.maybe_get_stream_name might return
// undefined. Otherwise, display the current stream name.
$(this).text("#" + stream_name + ' > ' + topic);
}
}
});