mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 14:03:30 +00:00 
			
		
		
		
	Move stream-related uri helpers to hash_util.
This allows several modules to no longer need to import `narrow` (or, in our current pre-import world, to not have to use that global). The broken dependencies are reflected in the node tests, which should now run slightly faster.
This commit is contained in:
		@@ -10,7 +10,6 @@ set_global('blueslip', global.make_zblueslip());
 | 
			
		||||
 | 
			
		||||
zrequire('util');
 | 
			
		||||
zrequire('hash_util');
 | 
			
		||||
zrequire('narrow');
 | 
			
		||||
zrequire('topic_data');
 | 
			
		||||
zrequire('people');
 | 
			
		||||
zrequire('stream_color');
 | 
			
		||||
 
 | 
			
		||||
@@ -11,7 +11,6 @@ zrequire('stream_sort');
 | 
			
		||||
zrequire('colorspace');
 | 
			
		||||
zrequire('stream_color');
 | 
			
		||||
zrequire('hash_util');
 | 
			
		||||
zrequire('narrow');
 | 
			
		||||
zrequire('unread');
 | 
			
		||||
zrequire('stream_data');
 | 
			
		||||
zrequire('scroll_util');
 | 
			
		||||
 
 | 
			
		||||
@@ -9,7 +9,6 @@ set_global('stream_popover', {});
 | 
			
		||||
set_global('templates', {});
 | 
			
		||||
 | 
			
		||||
zrequire('hash_util');
 | 
			
		||||
zrequire('narrow');
 | 
			
		||||
zrequire('stream_data');
 | 
			
		||||
zrequire('unread');
 | 
			
		||||
zrequire('topic_data');
 | 
			
		||||
 
 | 
			
		||||
@@ -55,6 +55,16 @@ 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_subject_uri = function (stream, subject) {
 | 
			
		||||
    return "#narrow/stream/" + exports.encode_stream_name(stream) +
 | 
			
		||||
           "/subject/" + exports.encodeHashComponent(subject);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
return exports;
 | 
			
		||||
 | 
			
		||||
}());
 | 
			
		||||
 
 | 
			
		||||
@@ -232,10 +232,11 @@ MessageListView.prototype = {
 | 
			
		||||
 | 
			
		||||
                if (message_container.msg.stream) {
 | 
			
		||||
                    message_container.stream_url =
 | 
			
		||||
                        narrow.by_stream_uri(message_container.msg.stream);
 | 
			
		||||
                        hash_util.by_stream_uri(message_container.msg.stream);
 | 
			
		||||
                    message_container.topic_url =
 | 
			
		||||
                        narrow.by_stream_subject_uri(message_container.msg.stream,
 | 
			
		||||
                                                     message_container.msg.subject);
 | 
			
		||||
                        hash_util.by_stream_subject_uri(
 | 
			
		||||
                            message_container.msg.stream,
 | 
			
		||||
                            message_container.msg.subject);
 | 
			
		||||
                } else {
 | 
			
		||||
                    message_container.pm_with_url =
 | 
			
		||||
                        message_container.msg.pm_with_url;
 | 
			
		||||
 
 | 
			
		||||
@@ -787,15 +787,6 @@ exports.by_sender_uri = function (reply_to) {
 | 
			
		||||
    ]);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
exports.by_stream_uri = function (stream) {
 | 
			
		||||
    return "#narrow/stream/" + hash_util.encode_stream_name(stream);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
exports.by_stream_subject_uri = function (stream, subject) {
 | 
			
		||||
    return "#narrow/stream/" + hash_util.encode_stream_name(stream) +
 | 
			
		||||
           "/subject/" + hash_util.encodeHashComponent(subject);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
exports.by_conversation_and_time_uri = function (message, is_absolute_url) {
 | 
			
		||||
    var absolute_url = "";
 | 
			
		||||
    if (is_absolute_url) {
 | 
			
		||||
 
 | 
			
		||||
@@ -228,7 +228,7 @@ exports.update_calculated_fields = function (sub) {
 | 
			
		||||
        !sub.invite_only || sub.subscribed);
 | 
			
		||||
    // User can add other users to stream if stream is public or user is subscribed to stream.
 | 
			
		||||
    sub.can_access_subscribers = !sub.invite_only || sub.subscribed || page_params.is_admin;
 | 
			
		||||
    sub.preview_url = narrow.by_stream_uri(sub.name);
 | 
			
		||||
    sub.preview_url = hash_util.by_stream_uri(sub.name);
 | 
			
		||||
    exports.render_stream_description(sub);
 | 
			
		||||
    exports.update_subscribers_count(sub);
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
@@ -220,7 +220,7 @@ function build_stream_sidebar_li(sub) {
 | 
			
		||||
    var args = {
 | 
			
		||||
        name: name,
 | 
			
		||||
        id: sub.stream_id,
 | 
			
		||||
        uri: narrow.by_stream_uri(name),
 | 
			
		||||
        uri: hash_util.by_stream_uri(name),
 | 
			
		||||
        not_in_home_view: stream_data.in_home_view(sub.stream_id) === false,
 | 
			
		||||
        invite_only: sub.invite_only,
 | 
			
		||||
        color: stream_data.get_color(name),
 | 
			
		||||
 
 | 
			
		||||
@@ -87,7 +87,7 @@ exports.widget = function (parent_elem, my_stream_id) {
 | 
			
		||||
                unread: num_unread,
 | 
			
		||||
                is_zero: num_unread === 0,
 | 
			
		||||
                is_muted: muting.is_topic_muted(my_stream_name, topic_name),
 | 
			
		||||
                url: narrow.by_stream_subject_uri(my_stream_name, topic_name),
 | 
			
		||||
                url: hash_util.by_stream_subject_uri(my_stream_name, topic_name),
 | 
			
		||||
            };
 | 
			
		||||
            var li = $(templates.render('topic_list_item', topic_info));
 | 
			
		||||
            self.topic_items.set(topic_name, li);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user