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)
This commit is contained in:
Keegan McAllister
2013-03-19 18:45:51 -04:00
parent ae27deb30f
commit e97c6f52ce
2 changed files with 13 additions and 4 deletions

View File

@@ -45,7 +45,10 @@ function parse_narrow(hash) {
} else { } else {
new_selection = initial_pointer; 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 // Returns true if this function performed a narrow

View File

@@ -271,7 +271,8 @@ function build_filter(operators_mixed_case) {
exports.activate = function (operators, opts) { exports.activate = function (operators, opts) {
opts = $.extend({}, { opts = $.extend({}, {
then_select_id: home_msg_list.selected_id(), then_select_id: home_msg_list.selected_id(),
select_first_unread: false select_first_unread: false,
change_hash: true
}, opts); }, opts);
// Unfade the home view before we switch tables. // Unfade the home view before we switch tables.
@@ -350,8 +351,13 @@ exports.activate = function (operators, opts) {
} }
search.update_highlighting(extract_search_terms(operators)); search.update_highlighting(extract_search_terms(operators));
// Put the narrow operators in the URL fragment and search bar // 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); hashchange.save_narrow(operators);
// Put the narrow operators in the search bar.
$('#search_query').val(unparse(operators)); $('#search_query').val(unparse(operators));
search.update_button_visibility(); search.update_button_visibility();
compose.update_recipient_on_narrow(); compose.update_recipient_on_narrow();