mirror of https://github.com/zulip/zulip.git
narrow: Simplify narrow operand processing code.
(imported from commit 9b353c3fab0d5c6532e844c9de45f10a7c6dc068)
This commit is contained in:
parent
6f57f62866
commit
8678148ad1
|
@ -353,12 +353,9 @@ exports.stream = function () {
|
||||||
if (current_filter === undefined) {
|
if (current_filter === undefined) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
var j;
|
var stream_operands = current_filter.operands("stream");
|
||||||
var current_operators = current_filter.operators();
|
if (stream_operands.length === 1) {
|
||||||
for (j = 0; j < current_operators.length; j++) {
|
return stream_operands[0];
|
||||||
if (current_operators[j][0] === "stream") {
|
|
||||||
return current_operators[j][1];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
};
|
};
|
||||||
|
@ -606,35 +603,25 @@ exports.by_stream_subject_uri = function (stream, subject) {
|
||||||
|
|
||||||
// Are we narrowed to PMs: all PMs or PMs with particular people.
|
// Are we narrowed to PMs: all PMs or PMs with particular people.
|
||||||
exports.narrowed_to_pms = function () {
|
exports.narrowed_to_pms = function () {
|
||||||
var i, filter = narrow.filter();
|
if (current_filter === undefined) {
|
||||||
if (filter === undefined) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (filter.operands("pm-with").length === 1) {
|
return (current_filter.has_operator("pm-with") ||
|
||||||
return true;
|
current_filter.has_operand("is", "private-message"));
|
||||||
}
|
|
||||||
var operands = filter.operands("is");
|
|
||||||
for (i = 0; i < operands.length; i++) {
|
|
||||||
if (operands[i] === "private-message") {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// We auto-reply under certain conditions, namely when you're narrowed
|
// We auto-reply under certain conditions, namely when you're narrowed
|
||||||
// to a PM (or huddle), and when you're narrowed to some stream/subject pair
|
// to a PM (or huddle), and when you're narrowed to some stream/subject pair
|
||||||
exports.narrowed_by_reply = function () {
|
exports.narrowed_by_reply = function () {
|
||||||
var filter = narrow.filter();
|
if (current_filter === undefined) {
|
||||||
if (filter === undefined) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var operators = filter.operators();
|
var operators = current_filter.operators();
|
||||||
return ((operators.length === 1 &&
|
return ((operators.length === 1 &&
|
||||||
filter.operands("pm-with").length === 1) ||
|
current_filter.operands("pm-with").length === 1) ||
|
||||||
(operators.length === 2 &&
|
(operators.length === 2 &&
|
||||||
filter.operands("stream").length === 1 &&
|
current_filter.operands("stream").length === 1 &&
|
||||||
filter.operands("subject").length === 1));
|
current_filter.operands("subject").length === 1));
|
||||||
};
|
};
|
||||||
|
|
||||||
return exports;
|
return exports;
|
||||||
|
|
Loading…
Reference in New Issue