From e97c6f52ce684b35f9ba504e57c7007a701cd452 Mon Sep 17 00:00:00 2001 From: Keegan McAllister Date: Tue, 19 Mar 2013 18:45:51 -0400 Subject: [PATCH] Don't save narrow operators to the URL fragment if that's where they came from In Firefox, prevents e.g. a slash in a stream name, which we wanted to store as %2F, from converting back to a literal slash. There is some appeal to normalizing the URL fragment after parsing, but in general this way seems better. It may decrease page load time on narrowed views. Doesn't yet fix #826; the URL is correct but the narrow is still wrong. (imported from commit 32e3fa9e968139863f34b9698f1c8b39d06f0c14) --- zephyr/static/js/hashchange.js | 5 ++++- zephyr/static/js/narrow.js | 12 +++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/zephyr/static/js/hashchange.js b/zephyr/static/js/hashchange.js index 99760dda21..4414b95a49 100644 --- a/zephyr/static/js/hashchange.js +++ b/zephyr/static/js/hashchange.js @@ -45,7 +45,10 @@ function parse_narrow(hash) { } else { new_selection = initial_pointer; } - narrow.activate(operators, {then_select_id: new_selection}); + narrow.activate(operators, { + then_select_id: new_selection, + change_hash: false // already set + }); } // Returns true if this function performed a narrow diff --git a/zephyr/static/js/narrow.js b/zephyr/static/js/narrow.js index 9c9a0e33db..3f04efdf14 100644 --- a/zephyr/static/js/narrow.js +++ b/zephyr/static/js/narrow.js @@ -271,7 +271,8 @@ function build_filter(operators_mixed_case) { exports.activate = function (operators, opts) { opts = $.extend({}, { then_select_id: home_msg_list.selected_id(), - select_first_unread: false + select_first_unread: false, + change_hash: true }, opts); // Unfade the home view before we switch tables. @@ -350,8 +351,13 @@ exports.activate = function (operators, opts) { } search.update_highlighting(extract_search_terms(operators)); - // Put the narrow operators in the URL fragment and search bar - hashchange.save_narrow(operators); + // Put the narrow operators in the URL fragment. + // Disabled when the URL fragment was the source + // of this narrow. + if (opts.change_hash) + hashchange.save_narrow(operators); + + // Put the narrow operators in the search bar. $('#search_query').val(unparse(operators)); search.update_button_visibility(); compose.update_recipient_on_narrow();