hashchange: Store `changing_hash` in browser_history state.

This will allow us to more widely access this variable and use it
outside of hashchange as well.
This commit is contained in:
Aman Agrawal 2021-04-09 11:53:45 +00:00 committed by Tim Abbott
parent 4a7de53554
commit fd2e0e7a1f
2 changed files with 6 additions and 6 deletions

View File

@ -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() {

View File

@ -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;
}