mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	refactor: Move operators_to_hash to hash_utils.
This breaks some unnecessary dependencies on hashchange.js, in favor of hash_util, which has fewer dependencies.
This commit is contained in:
		@@ -64,6 +64,28 @@ exports.by_stream_subject_uri = function (stream, subject) {
 | 
			
		||||
           "/subject/" + exports.encodeHashComponent(subject);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// Encodes an operator list into the
 | 
			
		||||
// corresponding hash: the # component
 | 
			
		||||
// of the narrow URL
 | 
			
		||||
exports.operators_to_hash = function (operators) {
 | 
			
		||||
    var hash = '#';
 | 
			
		||||
 | 
			
		||||
    if (operators !== undefined) {
 | 
			
		||||
        hash = '#narrow';
 | 
			
		||||
        _.each(operators, function (elem) {
 | 
			
		||||
            // Support legacy tuples.
 | 
			
		||||
            var operator = elem.operator;
 | 
			
		||||
            var operand = elem.operand;
 | 
			
		||||
 | 
			
		||||
            var sign = elem.negated ? '-' : '';
 | 
			
		||||
            hash += '/' + sign + exports.encodeHashComponent(operator)
 | 
			
		||||
                  + '/' + exports.encode_operand(operator, operand);
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return hash;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
return exports;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user