mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 06:53:25 +00:00
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:
@@ -2,10 +2,11 @@ import * as blueslip from "./blueslip";
|
|||||||
import * as hash_util from "./hash_util";
|
import * as hash_util from "./hash_util";
|
||||||
import * as ui_util from "./ui_util";
|
import * as ui_util from "./ui_util";
|
||||||
|
|
||||||
const state = {
|
export const state = {
|
||||||
is_internal_change: false,
|
is_internal_change: false,
|
||||||
hash_before_overlay: null,
|
hash_before_overlay: null,
|
||||||
old_hash: window.location.hash,
|
old_hash: window.location.hash,
|
||||||
|
changing_hash: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
export function clear_for_testing() {
|
export function clear_for_testing() {
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import * as ui_util from "./ui_util";
|
|||||||
|
|
||||||
// Read https://zulip.readthedocs.io/en/latest/subsystems/hashchange-system.html
|
// Read https://zulip.readthedocs.io/en/latest/subsystems/hashchange-system.html
|
||||||
// or locally: docs/subsystems/hashchange-system.md
|
// or locally: docs/subsystems/hashchange-system.md
|
||||||
let changing_hash = false;
|
|
||||||
|
|
||||||
function get_full_url(hash) {
|
function get_full_url(hash) {
|
||||||
const location = window.location;
|
const location = window.location;
|
||||||
@@ -70,7 +69,7 @@ export function in_recent_topics_hash() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function changehash(newhash) {
|
export function changehash(newhash) {
|
||||||
if (changing_hash) {
|
if (browser_history.state.changing_hash) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
maybe_hide_recent_topics();
|
maybe_hide_recent_topics();
|
||||||
@@ -79,7 +78,7 @@ export function changehash(newhash) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function save_narrow(operators) {
|
export function save_narrow(operators) {
|
||||||
if (changing_hash) {
|
if (browser_history.state.changing_hash) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const new_hash = hash_util.operators_to_hash(operators);
|
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.
|
// We are changing to a "main screen" view.
|
||||||
overlays.close_for_hash_change();
|
overlays.close_for_hash_change();
|
||||||
changing_hash = true;
|
browser_history.state.changing_hash = true;
|
||||||
const ret = do_hashchange_normal(from_reload);
|
const ret = do_hashchange_normal(from_reload);
|
||||||
changing_hash = false;
|
browser_history.state.changing_hash = false;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user