mirror of https://github.com/zulip/zulip.git
browser_history: Delay user_settings.default_view evaluation.
Commit 61f7ede43c
(#25759) introduced a
bug: browser_history tried to access user_settings.default_view at top
level as soon as it was imported, before
user_settings.initialize_user_settings has been called, so
browser_history.state.spectator_old_hash was always initialized to
"#undefined".
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
6988622fe8
commit
4650b789ce
|
@ -10,7 +10,7 @@ export const state: {
|
|||
hash_before_overlay: string | null;
|
||||
old_hash: string;
|
||||
changing_hash: boolean;
|
||||
spectator_old_hash: string;
|
||||
spectator_old_hash: string | null;
|
||||
} = {
|
||||
is_internal_change: false,
|
||||
hash_before_overlay: null,
|
||||
|
@ -22,7 +22,7 @@ export const state: {
|
|||
// hashes are changed without calling `hashchanged` in many ways.
|
||||
spectator_old_hash: hash_util.is_spectator_compatible(window.location.hash)
|
||||
? window.location.hash
|
||||
: `#${user_settings.default_view}`,
|
||||
: null,
|
||||
};
|
||||
|
||||
export function clear_for_testing(): void {
|
||||
|
@ -100,5 +100,5 @@ export function update_hash_internally_if_required(hash: string): void {
|
|||
}
|
||||
|
||||
export function return_to_web_public_hash(): void {
|
||||
window.location.hash = state.spectator_old_hash;
|
||||
window.location.hash = state.spectator_old_hash ?? `#${user_settings.default_view}`;
|
||||
}
|
||||
|
|
|
@ -8,13 +8,13 @@ const {run_test} = require("./lib/test");
|
|||
const blueslip = require("./lib/zblueslip");
|
||||
const {user_settings} = require("./lib/zpage_params");
|
||||
|
||||
user_settings.default_view = "recent";
|
||||
window.location.hash = "#bogus";
|
||||
|
||||
const browser_history = zrequire("browser_history");
|
||||
|
||||
function test(label, f) {
|
||||
run_test(label, (...args) => {
|
||||
user_settings.default_view = "recent";
|
||||
window.location.hash = "#bogus";
|
||||
browser_history.clear_for_testing();
|
||||
f(...args);
|
||||
|
|
Loading…
Reference in New Issue