compose_state: Maybe update stream name on stream name change.

If we rename a stream that we are composing to, we now change the
stream name in the compose target as well.
This commit is contained in:
Rohitt Vashishtha 2019-07-19 18:12:06 +00:00 committed by Tim Abbott
parent 3f03ae66f0
commit 5e6493d36e
1 changed files with 7 additions and 0 deletions

View File

@ -130,6 +130,8 @@ exports.is_subscribed_stream_tab_active = function () {
}; };
exports.update_stream_name = function (sub, new_name) { exports.update_stream_name = function (sub, new_name) {
var old_name = sub.name;
// Rename the stream internally. // Rename the stream internally.
stream_data.rename_sub(sub, new_name); stream_data.rename_sub(sub, new_name);
var stream_id = sub.stream_id; var stream_id = sub.stream_id;
@ -152,6 +154,11 @@ exports.update_stream_name = function (sub, new_name) {
// Clear rendered typeahead cache // Clear rendered typeahead cache
typeahead_helper.clear_rendered_stream(stream_id); typeahead_helper.clear_rendered_stream(stream_id);
// Update compose_state if needed
if (compose_state.stream_name() === old_name) {
compose_state.stream_name(new_name);
}
}; };
exports.update_stream_description = function (sub, description, rendered_description) { exports.update_stream_description = function (sub, description, rendered_description) {