mirror of https://github.com/zulip/zulip.git
hashchange: Extract function to update spectator_old_hash.
This commit is contained in:
parent
a7badd726f
commit
6da34fd283
|
@ -30,6 +30,15 @@ export function set_hash_before_overlay(hash) {
|
|||
state.hash_before_overlay = hash;
|
||||
}
|
||||
|
||||
export function update_web_public_hash(hash) {
|
||||
// Returns true if hash is web public compatible.
|
||||
if (hash_util.is_spectator_compatible(hash)) {
|
||||
state.spectator_old_hash = hash;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function save_old_hash() {
|
||||
state.old_hash = window.location.hash;
|
||||
|
||||
|
|
|
@ -315,14 +315,9 @@ function do_hashchange_overlay(old_hash) {
|
|||
function hashchanged(from_reload, e) {
|
||||
const current_hash = window.location.hash;
|
||||
const old_hash = e && (e.oldURL ? new URL(e.oldURL).hash : browser_history.old_hash());
|
||||
const is_hash_web_public_compatible = browser_history.update_web_public_hash(current_hash);
|
||||
|
||||
const was_internal_change = browser_history.save_old_hash();
|
||||
|
||||
const is_hash_web_public_compatible = hash_util.is_spectator_compatible(current_hash);
|
||||
if (is_hash_web_public_compatible) {
|
||||
browser_history.state.spectator_old_hash = current_hash;
|
||||
}
|
||||
|
||||
if (was_internal_change) {
|
||||
return undefined;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue