From f4f37fca146c61c7365e986bdaf6ea028e6ffda5 Mon Sep 17 00:00:00 2001 From: Aman Agrawal Date: Wed, 17 Feb 2021 12:32:58 +0000 Subject: [PATCH] hashchange: Extract func which checks current hash is in RT. --- frontend_tests/node_tests/hotkey.js | 4 +++- static/js/hashchange.js | 4 ++++ static/js/hotkey.js | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/frontend_tests/node_tests/hotkey.js b/frontend_tests/node_tests/hotkey.js index 5f1c3bd731..e1b011c135 100644 --- a/frontend_tests/node_tests/hotkey.js +++ b/frontend_tests/node_tests/hotkey.js @@ -50,7 +50,9 @@ zrequire("common"); const compose_actions = set_global("compose_actions", {}); const condense = set_global("condense", {}); const drafts = set_global("drafts", {}); -const hashchange = set_global("hashchange", {}); +const hashchange = set_global("hashchange", { + in_recent_topics_hash: () => false, +}); set_global("info_overlay", {}); const lightbox = set_global("lightbox", {}); const list_util = set_global("list_util", {}); diff --git a/static/js/hashchange.js b/static/js/hashchange.js index 0978a79cc5..691ed3c5dc 100644 --- a/static/js/hashchange.js +++ b/static/js/hashchange.js @@ -44,6 +44,10 @@ function maybe_hide_recent_topics() { return false; } +exports.in_recent_topics_hash = function () { + return ["recent_topics", "#", ""].includes(window.location.hash); +}; + exports.changehash = function (newhash) { if (changing_hash) { return; diff --git a/static/js/hotkey.js b/static/js/hotkey.js index 2ce0f25560..81eec56303 100644 --- a/static/js/hotkey.js +++ b/static/js/hotkey.js @@ -480,7 +480,7 @@ exports.process_hotkey = function (e, hotkey) { case "open_recent_topics": case "escape": if ( - ["#recent_topics", "#", ""].includes(window.location.hash) && + hashchange.in_recent_topics_hash() && !popovers.any_active() && !overlays.is_active() && !$("#searchbox_form #search_query").is(":focus") &&