mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 15:03:34 +00:00
PM sidebar: Expand PM sidebar for huddles.
This fixes a regression from here:
88b4a9f2d7
The fix didn't account for how huddles are
represented as comma-delimited strings.
We also simplify the logic by extracting a
function and doing early-exit for simple
cases.
This commit is contained in:
@@ -29,8 +29,15 @@ run_test('narrowing', () => {
|
|||||||
user_id: 1,
|
user_id: 1,
|
||||||
full_name: 'Alice Smith',
|
full_name: 'Alice Smith',
|
||||||
};
|
};
|
||||||
people.add(alice);
|
const bob = {
|
||||||
|
email: 'bob@example.com',
|
||||||
|
user_id: 2,
|
||||||
|
full_name: 'Bob Patel',
|
||||||
|
};
|
||||||
|
|
||||||
people.add_in_realm(alice);
|
people.add_in_realm(alice);
|
||||||
|
people.add_in_realm(bob);
|
||||||
|
|
||||||
pm_expanded = false;
|
pm_expanded = false;
|
||||||
filter = new Filter([
|
filter = new Filter([
|
||||||
{operator: 'pm-with', operand: 'alice@example.com'},
|
{operator: 'pm-with', operand: 'alice@example.com'},
|
||||||
@@ -38,6 +45,13 @@ run_test('narrowing', () => {
|
|||||||
top_left_corner.handle_narrow_activated(filter);
|
top_left_corner.handle_narrow_activated(filter);
|
||||||
assert(pm_expanded);
|
assert(pm_expanded);
|
||||||
|
|
||||||
|
pm_expanded = false;
|
||||||
|
filter = new Filter([
|
||||||
|
{operator: 'pm-with', operand: 'bob@example.com,alice@example.com'},
|
||||||
|
]);
|
||||||
|
top_left_corner.handle_narrow_activated(filter);
|
||||||
|
assert(pm_expanded);
|
||||||
|
|
||||||
pm_expanded = false;
|
pm_expanded = false;
|
||||||
filter = new Filter([
|
filter = new Filter([
|
||||||
{operator: 'pm-with', operand: 'not@valid.com'},
|
{operator: 'pm-with', operand: 'not@valid.com'},
|
||||||
|
|||||||
@@ -73,19 +73,35 @@ exports.handle_narrow_activated = function (filter) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var op_is = filter.operands('is');
|
if (exports.should_expand_pm_list(filter)) {
|
||||||
var op_pm = filter.operands('pm-with');
|
var op_pm = filter.operands('pm-with');
|
||||||
if (op_is.length >= 1 && _.contains(op_is, "private") || op_pm.length >= 1) {
|
|
||||||
if (!people.is_valid_bulk_emails_for_compose(op_pm)) {
|
|
||||||
// Don't go into the else statement and close the pm_list.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
pm_list.expand(op_pm);
|
pm_list.expand(op_pm);
|
||||||
} else {
|
} else {
|
||||||
pm_list.close();
|
pm_list.close();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.should_expand_pm_list = function (filter) {
|
||||||
|
var op_is = filter.operands('is');
|
||||||
|
|
||||||
|
if (op_is.length >= 1 && _.contains(op_is, "private")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
var op_pm = filter.operands('pm-with');
|
||||||
|
|
||||||
|
if (op_pm.length !== 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var emails_strings = op_pm[0];
|
||||||
|
var emails = emails_strings.split(',');
|
||||||
|
|
||||||
|
var has_valid_emails = people.is_valid_bulk_emails_for_compose(emails);
|
||||||
|
|
||||||
|
return has_valid_emails;
|
||||||
|
};
|
||||||
|
|
||||||
exports.handle_narrow_deactivated = function () {
|
exports.handle_narrow_deactivated = function () {
|
||||||
deselect_top_left_corner_items();
|
deselect_top_left_corner_items();
|
||||||
pm_list.close();
|
pm_list.close();
|
||||||
|
|||||||
Reference in New Issue
Block a user