mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	Fix support for searches like "in:home search:foo".
Previously, if you searched for "in:home search:foo", we weren't making "in:home" a public operator, so the back end wouldn't know to exclude muted messages, but the front end also wouldn't exclude muted messages, because it assumed that queries with "search:" in them were fully narrowed by the back end. Prior commits made it so that the back end is now capable of doing "in:home" narrowing, so to get the properly narrowed results, we simply needed to make in:home be a public operator in this commit. We also made in:all be public for convenience, although it's essentially a no-op. (imported from commit e4a8b10813b50163c431b1721bd316b676be1b83)
This commit is contained in:
		@@ -288,8 +288,8 @@ Filter.prototype = {
 | 
			
		||||
 | 
			
		||||
    public_operators: function Filter_public_operators() {
 | 
			
		||||
        var safe_to_return = _.filter(this._operators, function (value) {
 | 
			
		||||
            // Filter out the "in" keyword and the embedded narrow (if any).
 | 
			
		||||
            return value.operator !== 'in' && !(page_params.narrow_stream !== undefined &&
 | 
			
		||||
            // Filter out the embedded narrow (if any).
 | 
			
		||||
            return !(page_params.narrow_stream !== undefined &&
 | 
			
		||||
                     value.operator === "stream" &&
 | 
			
		||||
                     value.operand.toLowerCase() === page_params.narrow_stream.toLowerCase());
 | 
			
		||||
        });
 | 
			
		||||
 
 | 
			
		||||
@@ -95,18 +95,13 @@ function assert_same_operators(result, terms) {
 | 
			
		||||
(function test_public_operators() {
 | 
			
		||||
    var operators = [
 | 
			
		||||
        {operator: 'stream', operand: 'foo'},
 | 
			
		||||
        {operator: 'in', operand: 'all'},
 | 
			
		||||
        {operator: 'topic', operand: 'bar'}
 | 
			
		||||
    ];
 | 
			
		||||
 | 
			
		||||
    var filter = new Filter(operators);
 | 
			
		||||
    assert_same_operators(filter.public_operators(), operators);
 | 
			
		||||
 | 
			
		||||
    operators = [
 | 
			
		||||
        {operator: 'in', operand: 'all'}
 | 
			
		||||
    ];
 | 
			
		||||
    filter = new Filter(operators);
 | 
			
		||||
    assert_same_operators(filter.public_operators(), []);
 | 
			
		||||
 | 
			
		||||
    global.page_params.narrow_stream = 'default';
 | 
			
		||||
    operators = [
 | 
			
		||||
        {operator: 'stream', operand: 'default'}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user