diff --git a/frontend_tests/node_tests/stream_list.js b/frontend_tests/node_tests/stream_list.js index 1d275dca81..3c96d7318b 100644 --- a/frontend_tests/node_tests/stream_list.js +++ b/frontend_tests/node_tests/stream_list.js @@ -629,14 +629,10 @@ run_test('update_count_in_dom', () => { narrow_state.active = () => false; run_test('rename_stream', () => { - const old_stream_id = stream_data.get_stream_id('devel'); - const renamed_devel = { - name: 'Development', - stream_id: old_stream_id, - color: 'blue', - subscribed: true, - pin_to_top: true, - }; + const sub = stream_data.get_sub_by_name('devel'); + const new_name = 'Development'; + + stream_data.rename_sub(sub, new_name); const li_stub = $.create('li stub'); templates.render = (name, payload) => { @@ -644,7 +640,7 @@ run_test('rename_stream', () => { assert.deepEqual(payload, { name: 'Development', id: 1000, - uri: '#narrow/stream/Development', + uri: '#narrow/stream/1000-Development', not_in_home_view: false, invite_only: undefined, color: payload.color, @@ -660,7 +656,7 @@ run_test('rename_stream', () => { count_updated = true; }; - stream_list.rename_stream(renamed_devel); + stream_list.rename_stream(sub); assert(count_updated); }); diff --git a/static/js/click_handlers.js b/static/js/click_handlers.js index 0e11cb3a6d..b01ffe7a43 100644 --- a/static/js/click_handlers.js +++ b/static/js/click_handlers.js @@ -195,9 +195,9 @@ exports.initialize = function () { e.preventDefault(); // Note that we may have an href here, but we trust the stream id more, // so we re-encode the hash. - var stream = stream_data.get_sub_by_id($(this).attr('data-stream-id')); - if (stream) { - hashchange.go_to_location(hash_util.by_stream_uri(stream.name)); + var stream_id = $(this).attr('data-stream-id'); + if (stream_id) { + hashchange.go_to_location(hash_util.by_stream_uri(stream_id)); return; } window.location.href = $(this).attr('href'); diff --git a/static/js/hash_util.js b/static/js/hash_util.js index 79c58ce0ab..46314f9e2f 100644 --- a/static/js/hash_util.js +++ b/static/js/hash_util.js @@ -80,8 +80,8 @@ exports.decode_operand = function (operator, operand) { return operand; }; -exports.by_stream_uri = function (stream) { - return "#narrow/stream/" + exports.encode_stream_name(stream); +exports.by_stream_uri = function (stream_id) { + return "#narrow/stream/" + exports.encode_stream_id(stream_id); }; exports.by_stream_topic_uri = function (stream_id, subject) { diff --git a/static/js/message_list_view.js b/static/js/message_list_view.js index 056bf820fd..73bdf72c80 100644 --- a/static/js/message_list_view.js +++ b/static/js/message_list_view.js @@ -240,7 +240,7 @@ MessageListView.prototype = { if (message_container.msg.stream) { message_container.stream_url = - hash_util.by_stream_uri(message_container.msg.stream); + hash_util.by_stream_uri(message_container.msg.stream_id); message_container.topic_url = hash_util.by_stream_topic_uri( message_container.msg.stream_id, diff --git a/static/js/stream_data.js b/static/js/stream_data.js index 097340b2a5..6d2ed1abe7 100644 --- a/static/js/stream_data.js +++ b/static/js/stream_data.js @@ -242,7 +242,7 @@ exports.update_calculated_fields = function (sub) { // Guest users can't access subscribers of any(public or private) non-subscribed streams. sub.can_access_subscribers = page_params.is_admin || sub.subscribed || !page_params.is_guest && !sub.invite_only; - sub.preview_url = hash_util.by_stream_uri(sub.name); + sub.preview_url = hash_util.by_stream_uri(sub.stream_id); exports.render_stream_description(sub); exports.update_subscribers_count(sub); }; diff --git a/static/js/stream_list.js b/static/js/stream_list.js index 60b38e50fa..b7d78d2631 100644 --- a/static/js/stream_list.js +++ b/static/js/stream_list.js @@ -212,7 +212,7 @@ function build_stream_sidebar_li(sub) { var args = { name: name, id: sub.stream_id, - uri: hash_util.by_stream_uri(name), + uri: hash_util.by_stream_uri(sub.stream_id), not_in_home_view: stream_data.in_home_view(sub.stream_id) === false, invite_only: sub.invite_only, color: stream_data.get_color(name),