From b895780c7cb741406df0a8b364c63962b7a7bdec Mon Sep 17 00:00:00 2001 From: Jessica McKellar Date: Fri, 31 May 2013 11:43:32 -0400 Subject: [PATCH] Make narrow.operators always return an array. Previously it could return an array or boolean, and this inconsistent interface had several latent bugs where consumers of the API only considered it returning one or the other type. This also fixes a specific bug a user triggered by being narrowed to nothing (/#narrow) and clicking in the compose box. (imported from commit 64ca2a37a9f288066f89b0ddec6638e010704eb0) --- zephyr/static/js/narrow.js | 4 ++-- zephyr/static/js/subs.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/zephyr/static/js/narrow.js b/zephyr/static/js/narrow.js index 2055f09d7f..2308917da5 100644 --- a/zephyr/static/js/narrow.js +++ b/zephyr/static/js/narrow.js @@ -164,7 +164,7 @@ exports.predicate = function () { exports.operators = function () { if (current_filter === undefined) { - return false; + return []; } return current_filter.operators(); }; @@ -618,7 +618,7 @@ exports.by_stream_subject_uri = function (stream, subject) { exports.narrowed_to_pms = function () { // Are we narrowed to PMs: all PMs or PMs with particular people. var operators = narrow.operators(); - if (!operators) { + if (operators.length === 0) { return false; } if ((operators[0][0] === "pm-with") || diff --git a/zephyr/static/js/subs.js b/zephyr/static/js/subs.js index ee5e8b66ea..be2d69cb81 100644 --- a/zephyr/static/js/subs.js +++ b/zephyr/static/js/subs.js @@ -926,7 +926,7 @@ $(function () { function focus_on_narrowed_stream() { var operators = narrow.operators(); - if (!operators) { + if (operators.length === 0) { return; } var stream_name = operators[0][1];