Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

hashchange: Store `changing_hash` in browser_history state.

Aman Agrawalfd2e0e7a1f11
diff --git a/static/js/browser_history.js b/static/js/browser_history.js
index 6b75d50017e..0d9de382d3c 100644
--- a/static/js/browser_history.js
+++ b/static/js/browser_history.js
@@ -2,10 +2,11 @@ import * as blueslip from "./blueslip";
import * as hash_util from "./hash_util";
import * as ui_util from "./ui_util";
-const state = {
+export const state = {
is_internal_change: false,
hash_before_overlay: null,
old_hash: window.location.hash,
+ changing_hash: false,
};
export function clear_for_testing() {
diff --git a/static/js/hashchange.js b/static/js/hashchange.js
index fa551fd04b4..b07ec9be760 100644
--- a/static/js/hashchange.js
+++ b/static/js/hashchange.js
@@ -25,7 +25,6 @@ import * as ui_util from "./ui_util";
// Read https://zulip.readthedocs.io/en/latest/subsystems/hashchange-system.html
// or locally: docs/subsystems/hashchange-system.md
-let changing_hash = false;
function get_full_url(hash) {
const location = window.location;
@@ -70,7 +69,7 @@ export function in_recent_topics_hash() {
}
export function changehash(newhash) {
- if (changing_hash) {
+ if (browser_history.state.changing_hash) {
return;
}
maybe_hide_recent_topics();
@@ -79,7 +78,7 @@ export function changehash(newhash) {
}
export function save_narrow(operators) {
- if (changing_hash) {
+ if (browser_history.state.changing_hash) {
return;
}
const new_hash = hash_util.operators_to_hash(operators);
@@ -296,9 +295,9 @@ function hashchanged(from_reload, e) {
// We are changing to a "main screen" view.
overlays.close_for_hash_change();
- changing_hash = true;
+ browser_history.state.changing_hash = true;
const ret = do_hashchange_normal(from_reload);
- changing_hash = false;
+ browser_history.state.changing_hash = false;
return ret;
}