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: Extract function to update spectator_old_hash.

Aman Agrawal6da34fd283ad
diff --git a/static/js/browser_history.js b/static/js/browser_history.js
index 654c80825a3..db670112675 100644
--- a/static/js/browser_history.js
+++ b/static/js/browser_history.js
@@ -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;
diff --git a/static/js/hashchange.js b/static/js/hashchange.js
index 0d3c41e03b4..35567adafd2 100644
--- a/static/js/hashchange.js
+++ b/static/js/hashchange.js
@@ -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;
}