hashchange: Go through hashchange to narrow to All messsages.

We should not allow every function who wants to narrow to All
messages to come up with their own method to do so. This
commit makes existing such functions use hashchange library to
do so.

Remove click event on All message button, it already contains
an <a> tag which navigates correctly.
This commit is contained in:
Aman Agrawal
2020-07-03 14:08:24 +05:30
committed by Tim Abbott
parent 8b29c38e62
commit 0859a91b14
6 changed files with 13 additions and 13 deletions

View File

@@ -10,7 +10,11 @@ zrequire("people");
zrequire("hash_util");
zrequire("hashchange");
zrequire("stream_data");
zrequire("navigate");
set_global("search", {
update_button_visibility: () => {},
});
set_global("document", "document-stub");
set_global("history", {});

View File

@@ -569,16 +569,6 @@ exports.initialize = function () {
// HOME
$(document).on("click", ".top_left_all_messages", (e) => {
ui_util.change_tab_to("#home");
narrow.deactivate();
search.update_button_visibility();
// We need to maybe scroll to the selected message
// once we have the proper viewport set up
setTimeout(navigate.maybe_scroll_to_selected, 0);
e.preventDefault();
});
$(".brand").on("click", (e) => {
if (overlays.is_active()) {
overlays.close_active();

View File

@@ -52,6 +52,10 @@ function activate_home_tab() {
ui_util.change_tab_to("#home");
narrow.deactivate();
floating_recipient_bar.update();
search.update_button_visibility();
// We need to maybe scroll to the selected message
// once we have the proper viewport set up
setTimeout(navigate.maybe_scroll_to_selected, 0);
}
const state = {

View File

@@ -264,7 +264,7 @@ exports.process_escape_key = function (e) {
return true;
}
narrow.deactivate();
hashchange.go_to_location("");
return true;
};

View File

@@ -762,6 +762,9 @@ function handle_post_narrow_deactivate_processes() {
}
exports.deactivate = function () {
// NOTE: Never call this function independently,
// always use hashchange.go_to_location("") to
// activate All message narrow.
/*
Switches current_msg_list from narrowed_msg_list to
home_msg_list ("All messages"), ending the current narrow. This

View File

@@ -7,8 +7,7 @@ exports.initialize = function () {
exports.widget.onPillRemove(() => {
if (exports.widget.items().length === 0) {
ui_util.change_tab_to("#home");
narrow.deactivate();
hashchange.go_to_location("");
}
});