mirror of
https://github.com/zulip/zulip.git
synced 2025-10-24 16:43:57 +00:00
Use stream_id for by_stream__uri().
The stream_list test that was fixed here was sort of broken. It accomplished the main goal of verifying what gets rendered, but now the data setup part is more like the actual app code (and simpler, too).
This commit is contained in:
@@ -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);
|
||||
});
|
||||
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user