mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	invite: Display and check default streams in invite modal.
This fixes two bugs: * If a user is not subscribed to a default stream, he or she would not be have the option to invite users to that default stream. * The initial streams checked in the invite modal were the non-invite-only streams the user was subscribed to, not their default streams. Fixes: #4209.
This commit is contained in:
		@@ -9,6 +9,8 @@ var stream_info;
 | 
			
		||||
var subs_by_stream_id;
 | 
			
		||||
var recent_topics = new Dict({fold_case: true});
 | 
			
		||||
 | 
			
		||||
var defaults = {};
 | 
			
		||||
 | 
			
		||||
exports.clear_subscriptions = function () {
 | 
			
		||||
    stream_info = new Dict({fold_case: true});
 | 
			
		||||
    subs_by_stream_id = new Dict();
 | 
			
		||||
@@ -79,6 +81,12 @@ exports.subscribed_streams = function () {
 | 
			
		||||
    return _.pluck(exports.subscribed_subs(), 'name');
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
exports.invite_streams = function () {
 | 
			
		||||
    var invite_list = exports.subscribed_streams();
 | 
			
		||||
    var default_list = _.pluck(page_params.realm_default_streams, 'name');
 | 
			
		||||
    return _.union(invite_list, default_list);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
exports.get_colors = function () {
 | 
			
		||||
    return _.pluck(exports.subscribed_subs(), 'color');
 | 
			
		||||
};
 | 
			
		||||
@@ -134,6 +142,10 @@ exports.get_invite_only = function (stream_name) {
 | 
			
		||||
    return sub.invite_only;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
exports.get_default_status = function (stream_name) {
 | 
			
		||||
    return defaults.hasOwnProperty(stream_name);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
exports.get_name = function (stream_name) {
 | 
			
		||||
    // This returns the actual name of a stream if we are subscribed to
 | 
			
		||||
    // it (i.e "Denmark" vs. "denmark"), while falling thru to
 | 
			
		||||
@@ -373,6 +385,10 @@ exports.initialize_from_page_params = function () {
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    page_params.realm_default_streams.forEach(function (stream) {
 | 
			
		||||
        defaults[stream.name] = true;
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    populate_subscriptions(page_params.subbed_info, true);
 | 
			
		||||
    populate_subscriptions(page_params.unsubbed_info, false);
 | 
			
		||||
    populate_subscriptions(page_params.neversubbed_info, false);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user