hotkey: Render default_view via changing hash.

Directly rendering the default view on pressing `escape` key will lead
to default_view being rendered on the current window hash.  So, we set
empty hash to load default view and let hashchange handle it.

This fixes a bug introduced in
59a45d3521.
This commit is contained in:
Aman Agrawal 2021-05-12 21:38:55 +00:00 committed by Tim Abbott
parent 3d6af7a3c8
commit 3cb7ffd61a
2 changed files with 9 additions and 2 deletions

View File

@ -94,7 +94,14 @@ function show_all_message_view() {
setTimeout(navigate.maybe_scroll_to_selected, 0);
}
export function show_default_view() {
export function set_hash_to_default_view() {
window.location.hash = "";
}
function show_default_view() {
// This function should only be called from the hashchange
// handlers, as it does not set the hash to "".
//
// We only allow all_messages and recent_topics
// to be rendered without a hash.
if (page_params.default_view === "recent_topics") {

View File

@ -332,7 +332,7 @@ export function process_escape_key(e) {
return true;
}
hashchange.show_default_view();
hashchange.set_hash_to_default_view();
return true;
}