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:
Steve Howell
2014-02-28 15:12:02 -05:00
parent e7769d9004
commit 957486cc95
2 changed files with 5 additions and 10 deletions

View File

@@ -288,10 +288,10 @@ 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 &&
value.operator === "stream" &&
value.operand.toLowerCase() === page_params.narrow_stream.toLowerCase());
// Filter out the embedded narrow (if any).
return !(page_params.narrow_stream !== undefined &&
value.operator === "stream" &&
value.operand.toLowerCase() === page_params.narrow_stream.toLowerCase());
});
return safe_to_return;
},

View File

@@ -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'}