2021-03-11 05:43:45 +01:00
|
|
|
import $ from "jquery";
|
|
|
|
|
2021-02-09 11:16:52 +01:00
|
|
|
import * as about_zulip from "./about_zulip";
|
2021-02-28 01:23:35 +01:00
|
|
|
import * as admin from "./admin";
|
2021-03-16 23:38:59 +01:00
|
|
|
import * as blueslip from "./blueslip";
|
2021-03-22 16:09:12 +01:00
|
|
|
import * as browser_history from "./browser_history";
|
2021-02-28 01:07:47 +01:00
|
|
|
import * as drafts from "./drafts";
|
|
|
|
import * as floating_recipient_bar from "./floating_recipient_bar";
|
|
|
|
import * as hash_util from "./hash_util";
|
2022-02-25 19:34:01 +01:00
|
|
|
import {$t_html} from "./i18n";
|
2021-02-28 01:07:47 +01:00
|
|
|
import * as info_overlay from "./info_overlay";
|
|
|
|
import * as invite from "./invite";
|
2021-03-30 02:21:21 +02:00
|
|
|
import * as message_lists from "./message_lists";
|
2021-02-28 01:07:47 +01:00
|
|
|
import * as message_viewport from "./message_viewport";
|
2021-02-28 21:31:57 +01:00
|
|
|
import * as narrow from "./narrow";
|
2021-02-28 01:07:47 +01:00
|
|
|
import * as navigate from "./navigate";
|
|
|
|
import * as overlays from "./overlays";
|
2021-03-25 22:35:45 +01:00
|
|
|
import {page_params} from "./page_params";
|
2021-06-10 14:18:46 +02:00
|
|
|
import * as recent_topics_ui from "./recent_topics_ui";
|
|
|
|
import * as recent_topics_util from "./recent_topics_util";
|
2021-02-28 01:07:47 +01:00
|
|
|
import * as search from "./search";
|
2021-02-28 01:23:16 +01:00
|
|
|
import * as settings from "./settings";
|
2021-02-28 01:07:47 +01:00
|
|
|
import * as settings_panel_menu from "./settings_panel_menu";
|
2021-03-16 07:22:28 +01:00
|
|
|
import * as settings_toggle from "./settings_toggle";
|
2021-09-07 04:09:12 +02:00
|
|
|
import * as spectators from "./spectators";
|
2021-07-09 15:51:31 +02:00
|
|
|
import * as stream_settings_ui from "./stream_settings_ui";
|
2021-02-28 01:07:47 +01:00
|
|
|
import * as top_left_corner from "./top_left_corner";
|
2022-02-25 19:27:25 +01:00
|
|
|
import * as ui_report from "./ui_report";
|
2022-02-25 19:34:01 +01:00
|
|
|
import * as ui_util from "./ui_util";
|
2022-08-21 16:34:56 +02:00
|
|
|
import * as user_groups_settings_ui from "./user_groups_settings_ui";
|
2021-07-28 16:00:58 +02:00
|
|
|
import {user_settings} from "./user_settings";
|
2021-02-10 17:00:58 +01:00
|
|
|
|
2017-11-16 19:51:44 +01:00
|
|
|
// Read https://zulip.readthedocs.io/en/latest/subsystems/hashchange-system.html
|
2018-12-04 23:01:41 +01:00
|
|
|
// or locally: docs/subsystems/hashchange-system.md
|
2012-12-07 20:52:39 +01:00
|
|
|
|
2018-12-06 22:49:26 +01:00
|
|
|
function get_full_url(hash) {
|
2019-11-02 00:06:25 +01:00
|
|
|
const location = window.location;
|
2014-02-13 05:38:02 +01:00
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
if (hash === "" || hash.charAt(0) !== "#") {
|
|
|
|
hash = "#" + hash;
|
2018-12-06 22:49:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// IE returns pathname as undefined and missing the leading /
|
2019-11-02 00:06:25 +01:00
|
|
|
let pathname = location.pathname;
|
2018-12-06 22:49:26 +01:00
|
|
|
if (pathname === undefined) {
|
2020-07-15 01:29:15 +02:00
|
|
|
pathname = "/";
|
|
|
|
} else if (pathname === "" || pathname.charAt(0) !== "/") {
|
|
|
|
pathname = "/" + pathname;
|
2018-12-06 22:49:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Build a full URL to not have same origin problems
|
2020-07-16 23:29:01 +02:00
|
|
|
const url = location.protocol + "//" + location.host + pathname + hash;
|
2018-12-06 22:49:26 +01:00
|
|
|
return url;
|
|
|
|
}
|
|
|
|
|
|
|
|
function set_hash(hash) {
|
2014-01-29 22:14:00 +01:00
|
|
|
if (history.pushState) {
|
2019-11-02 00:06:25 +01:00
|
|
|
const url = get_full_url(hash);
|
2014-01-29 22:14:00 +01:00
|
|
|
history.pushState(null, null, url);
|
2021-11-17 13:24:41 +01:00
|
|
|
browser_history.update_web_public_hash(hash);
|
2014-01-29 22:14:00 +01:00
|
|
|
} else {
|
2020-07-15 01:29:15 +02:00
|
|
|
blueslip.warn("browser does not support pushState");
|
2018-12-06 22:49:26 +01:00
|
|
|
window.location.hash = hash;
|
2014-01-29 22:14:00 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-05 12:19:09 +02:00
|
|
|
function maybe_hide_recent_topics() {
|
2021-06-10 14:18:46 +02:00
|
|
|
if (recent_topics_util.is_visible()) {
|
|
|
|
recent_topics_ui.hide();
|
2020-07-05 12:19:09 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-02-28 01:07:47 +01:00
|
|
|
export function changehash(newhash) {
|
2021-04-09 13:53:45 +02:00
|
|
|
if (browser_history.state.changing_hash) {
|
2013-04-03 20:44:26 +02:00
|
|
|
return;
|
|
|
|
}
|
2020-07-05 12:19:09 +02:00
|
|
|
maybe_hide_recent_topics();
|
2018-12-04 19:08:26 +01:00
|
|
|
message_viewport.stop_auto_scrolling();
|
2014-01-29 22:14:00 +01:00
|
|
|
set_hash(newhash);
|
2021-02-28 01:07:47 +01:00
|
|
|
}
|
2012-12-07 20:52:39 +01:00
|
|
|
|
2021-02-28 01:07:47 +01:00
|
|
|
export function save_narrow(operators) {
|
2021-04-09 13:53:45 +02:00
|
|
|
if (browser_history.state.changing_hash) {
|
2013-04-03 20:44:26 +02:00
|
|
|
return;
|
|
|
|
}
|
2019-11-02 00:06:25 +01:00
|
|
|
const new_hash = hash_util.operators_to_hash(operators);
|
2021-02-28 01:07:47 +01:00
|
|
|
changehash(new_hash);
|
|
|
|
}
|
2012-12-12 19:00:50 +01:00
|
|
|
|
2021-03-15 17:17:31 +01:00
|
|
|
function show_all_message_view() {
|
2020-07-05 12:19:09 +02:00
|
|
|
const coming_from_recent_topics = maybe_hide_recent_topics();
|
2020-07-04 16:25:41 +02:00
|
|
|
ui_util.change_tab_to("#message_feed_container");
|
2020-07-05 12:19:09 +02:00
|
|
|
narrow.deactivate(coming_from_recent_topics);
|
2020-09-20 10:14:24 +02:00
|
|
|
top_left_corner.handle_narrow_deactivated();
|
2014-03-13 21:14:33 +01:00
|
|
|
floating_recipient_bar.update();
|
2020-07-03 10:38:24 +02:00
|
|
|
search.update_button_visibility();
|
|
|
|
// We need to maybe scroll to the selected message
|
|
|
|
// once we have the proper viewport set up
|
|
|
|
setTimeout(navigate.maybe_scroll_to_selected, 0);
|
2012-12-12 19:00:50 +01:00
|
|
|
}
|
|
|
|
|
2021-05-12 23:38:55 +02:00
|
|
|
export function set_hash_to_default_view() {
|
|
|
|
window.location.hash = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
function show_default_view() {
|
|
|
|
// This function should only be called from the hashchange
|
|
|
|
// handlers, as it does not set the hash to "".
|
|
|
|
//
|
2021-03-15 15:01:19 +01:00
|
|
|
// We only allow all_messages and recent_topics
|
|
|
|
// to be rendered without a hash.
|
2021-07-28 16:00:58 +02:00
|
|
|
if (user_settings.default_view === "recent_topics") {
|
2021-06-10 14:18:46 +02:00
|
|
|
recent_topics_ui.show();
|
2021-07-28 16:00:58 +02:00
|
|
|
} else if (user_settings.default_view === "all_messages") {
|
2021-03-15 17:17:31 +01:00
|
|
|
show_all_message_view();
|
2021-03-15 15:01:19 +01:00
|
|
|
} else {
|
|
|
|
// NOTE: Setting a hash which is not rendered on
|
|
|
|
// empty hash (like a stream narrow) will
|
|
|
|
// introduce a bug that user will not be able to
|
2021-05-18 14:44:05 +02:00
|
|
|
// go back in browser history. See
|
2021-03-15 15:01:19 +01:00
|
|
|
// https://chat.zulip.org/#narrow/stream/9-issues/topic/Browser.20back.20button.20on.20RT
|
|
|
|
// for detailed description of the issue.
|
2021-07-28 16:00:58 +02:00
|
|
|
window.location.hash = user_settings.default_view;
|
2021-03-15 15:01:19 +01:00
|
|
|
}
|
2021-03-10 13:56:10 +01:00
|
|
|
}
|
|
|
|
|
2012-12-21 01:04:27 +01:00
|
|
|
// Returns true if this function performed a narrow
|
2018-12-04 19:00:01 +01:00
|
|
|
function do_hashchange_normal(from_reload) {
|
2018-12-04 19:08:26 +01:00
|
|
|
message_viewport.stop_auto_scrolling();
|
2013-04-23 21:59:49 +02:00
|
|
|
|
2013-03-20 00:22:51 +01:00
|
|
|
// NB: In Firefox, window.location.hash is URI-decoded.
|
|
|
|
// Even if the URL bar says #%41%42%43%44, the value here will
|
|
|
|
// be #ABCD.
|
2019-11-02 00:06:25 +01:00
|
|
|
const hash = window.location.hash.split("/");
|
2021-06-28 05:08:55 +02:00
|
|
|
|
2012-12-19 21:19:29 +01:00
|
|
|
switch (hash[0]) {
|
2020-07-15 02:14:03 +02:00
|
|
|
case "#narrow": {
|
2020-07-05 12:19:09 +02:00
|
|
|
maybe_hide_recent_topics();
|
2020-07-04 16:25:41 +02:00
|
|
|
ui_util.change_tab_to("#message_feed_container");
|
2022-02-25 19:34:01 +01:00
|
|
|
let operators;
|
2022-02-25 19:27:25 +01:00
|
|
|
try {
|
|
|
|
// TODO: Show possible valid URLs to the user.
|
|
|
|
operators = hash_util.parse_narrow(hash);
|
|
|
|
} catch {
|
|
|
|
ui_report.error(
|
|
|
|
$t_html({defaultMessage: "Invalid URL"}),
|
|
|
|
undefined,
|
|
|
|
$("#home-error"),
|
|
|
|
2000,
|
|
|
|
);
|
|
|
|
}
|
2020-07-15 02:14:03 +02:00
|
|
|
if (operators === undefined) {
|
2021-03-15 15:01:19 +01:00
|
|
|
// If the narrow URL didn't parse,
|
|
|
|
// send them to default_view.
|
|
|
|
// We cannot clear hash here since
|
|
|
|
// it will block user from going back
|
|
|
|
// in browser history.
|
2021-03-10 13:56:10 +01:00
|
|
|
show_default_view();
|
2020-07-15 02:14:03 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
const narrow_opts = {
|
2020-07-16 23:29:01 +02:00
|
|
|
change_hash: false, // already set
|
2020-07-15 02:14:03 +02:00
|
|
|
trigger: "hash change",
|
|
|
|
};
|
|
|
|
if (from_reload) {
|
|
|
|
blueslip.debug("We are narrowing as part of a reload.");
|
|
|
|
if (page_params.initial_narrow_pointer !== undefined) {
|
2021-03-30 02:21:21 +02:00
|
|
|
message_lists.home.pre_narrow_offset = page_params.initial_offset;
|
2020-07-15 02:14:03 +02:00
|
|
|
narrow_opts.then_select_id = page_params.initial_narrow_pointer;
|
|
|
|
narrow_opts.then_select_offset = page_params.initial_narrow_offset;
|
|
|
|
}
|
2017-06-15 18:30:40 +02:00
|
|
|
}
|
2020-07-15 02:14:03 +02:00
|
|
|
narrow.activate(operators, narrow_opts);
|
|
|
|
floating_recipient_bar.update();
|
|
|
|
return true;
|
2014-02-12 20:03:05 +01:00
|
|
|
}
|
2020-07-15 02:14:03 +02:00
|
|
|
case "":
|
|
|
|
case "#":
|
2021-03-10 13:56:10 +01:00
|
|
|
show_default_view();
|
|
|
|
break;
|
2020-07-05 12:19:09 +02:00
|
|
|
case "#recent_topics":
|
2021-06-10 14:18:46 +02:00
|
|
|
recent_topics_ui.show();
|
2020-07-05 12:19:09 +02:00
|
|
|
break;
|
2020-09-20 10:14:24 +02:00
|
|
|
case "#all_messages":
|
2021-03-15 17:17:31 +01:00
|
|
|
show_all_message_view();
|
2020-09-20 10:14:24 +02:00
|
|
|
break;
|
2020-07-15 02:14:03 +02:00
|
|
|
case "#keyboard-shortcuts":
|
|
|
|
case "#message-formatting":
|
|
|
|
case "#search-operators":
|
|
|
|
case "#drafts":
|
|
|
|
case "#invite":
|
|
|
|
case "#streams":
|
|
|
|
case "#organization":
|
|
|
|
case "#settings":
|
2021-02-09 11:16:52 +01:00
|
|
|
case "#about-zulip":
|
2020-07-15 02:14:03 +02:00
|
|
|
blueslip.error("overlay logic skipped for: " + hash);
|
|
|
|
break;
|
2021-06-19 06:58:15 +02:00
|
|
|
default:
|
|
|
|
show_default_view();
|
2012-12-07 20:52:39 +01:00
|
|
|
}
|
2012-12-21 01:04:27 +01:00
|
|
|
return false;
|
2012-12-07 20:52:39 +01:00
|
|
|
}
|
|
|
|
|
2018-12-04 19:00:01 +01:00
|
|
|
function do_hashchange_overlay(old_hash) {
|
2020-11-04 09:10:18 +01:00
|
|
|
if (old_hash === undefined) {
|
2021-05-12 17:18:08 +02:00
|
|
|
// The user opened the app with an overlay hash; we need to
|
|
|
|
// show the user's default view behind it.
|
|
|
|
show_default_view();
|
2020-11-04 09:10:18 +01:00
|
|
|
}
|
2021-03-23 05:14:54 +01:00
|
|
|
const base = hash_util.get_current_hash_category();
|
2019-11-02 00:06:25 +01:00
|
|
|
const old_base = hash_util.get_hash_category(old_hash);
|
2021-03-23 05:14:54 +01:00
|
|
|
const section = hash_util.get_current_hash_section();
|
2018-12-01 01:08:48 +01:00
|
|
|
|
2021-03-22 16:09:12 +01:00
|
|
|
const coming_from_overlay = hash_util.is_overlay_hash(old_hash || "#");
|
2018-12-01 01:08:48 +01:00
|
|
|
|
2022-02-07 12:01:58 +01:00
|
|
|
if ((base === "settings" || base === "organization") && !section) {
|
|
|
|
let settings_panel_object = settings_panel_menu.normal_settings;
|
|
|
|
if (base === "organization") {
|
|
|
|
settings_panel_object = settings_panel_menu.org_settings;
|
|
|
|
}
|
|
|
|
history.replaceState(
|
|
|
|
null,
|
|
|
|
"",
|
|
|
|
get_full_url(base + "/" + settings_panel_object.current_tab()),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-02-08 12:07:40 +01:00
|
|
|
if (base === "streams" && !section) {
|
|
|
|
history.replaceState(null, "", get_full_url("streams/subscribed"));
|
|
|
|
}
|
|
|
|
|
2018-12-01 18:54:41 +01:00
|
|
|
// Start by handling the specific case of going
|
|
|
|
// from something like streams/all to streams_subscribed.
|
|
|
|
//
|
|
|
|
// In most situations we skip by this logic and load
|
|
|
|
// the new overlay.
|
2020-12-22 11:26:39 +01:00
|
|
|
if (coming_from_overlay && base === old_base) {
|
|
|
|
if (base === "streams") {
|
2021-07-09 15:51:31 +02:00
|
|
|
stream_settings_ui.change_state(section);
|
2020-12-22 11:26:39 +01:00
|
|
|
return;
|
|
|
|
}
|
2018-12-06 22:28:52 +01:00
|
|
|
|
2020-12-22 11:26:39 +01:00
|
|
|
if (base === "settings") {
|
|
|
|
if (!section) {
|
|
|
|
// We may be on a really old browser or somebody
|
|
|
|
// hand-typed a hash.
|
|
|
|
blueslip.warn("missing section for settings");
|
2018-12-06 22:28:52 +01:00
|
|
|
}
|
2020-12-22 11:26:39 +01:00
|
|
|
settings_panel_menu.normal_settings.activate_section_or_default(section);
|
|
|
|
return;
|
|
|
|
}
|
2018-12-06 22:28:52 +01:00
|
|
|
|
2020-12-22 11:26:39 +01:00
|
|
|
if (base === "organization") {
|
|
|
|
if (!section) {
|
|
|
|
// We may be on a really old browser or somebody
|
|
|
|
// hand-typed a hash.
|
|
|
|
blueslip.warn("missing section for organization");
|
2018-12-01 18:54:41 +01:00
|
|
|
}
|
2020-12-22 11:26:39 +01:00
|
|
|
settings_panel_menu.org_settings.activate_section_or_default(section);
|
2018-12-01 18:54:41 +01:00
|
|
|
return;
|
2018-12-01 01:08:48 +01:00
|
|
|
}
|
2020-12-22 11:26:39 +01:00
|
|
|
|
|
|
|
// TODO: handle other cases like internal settings
|
|
|
|
// changes.
|
|
|
|
return;
|
2018-12-01 18:54:41 +01:00
|
|
|
}
|
2018-12-01 01:08:48 +01:00
|
|
|
|
2021-03-16 07:22:28 +01:00
|
|
|
// This is a special case when user clicks on a URL that makes the overlay switch
|
|
|
|
// from org settings to user settings or user edits the URL to switch between them.
|
|
|
|
const settings_hashes = new Set(["settings", "organization"]);
|
|
|
|
// Ensure that we are just switching between user and org settings and the settings
|
|
|
|
// overlay is open.
|
|
|
|
const is_hashchange_internal =
|
|
|
|
settings_hashes.has(base) && settings_hashes.has(old_base) && overlays.settings_open();
|
|
|
|
if (is_hashchange_internal) {
|
2021-07-01 20:19:33 +02:00
|
|
|
if (base === "settings") {
|
|
|
|
settings_panel_menu.normal_settings.activate_section_or_default(section);
|
|
|
|
} else {
|
|
|
|
settings_panel_menu.org_settings.activate_section_or_default(section);
|
|
|
|
}
|
2021-07-01 20:46:37 +02:00
|
|
|
settings_toggle.highlight_toggle(base);
|
2021-03-16 07:22:28 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-12-01 18:54:41 +01:00
|
|
|
// It's not super likely that an overlay is already open,
|
|
|
|
// but you can jump from /settings to /streams by using
|
|
|
|
// the browser's history menu or hand-editing the URL or
|
|
|
|
// whatever. If so, just close the overlays.
|
2018-12-03 18:11:14 +01:00
|
|
|
if (base !== old_base) {
|
2018-12-01 18:54:41 +01:00
|
|
|
overlays.close_for_hash_change();
|
|
|
|
}
|
2018-12-01 01:08:48 +01:00
|
|
|
|
2018-12-01 18:54:41 +01:00
|
|
|
// NORMAL FLOW: basically, launch the overlay:
|
|
|
|
|
|
|
|
if (!coming_from_overlay) {
|
2021-03-22 16:09:12 +01:00
|
|
|
browser_history.set_hash_before_overlay(old_hash);
|
2018-12-01 01:08:48 +01:00
|
|
|
}
|
2018-12-01 18:54:41 +01:00
|
|
|
|
|
|
|
if (base === "streams") {
|
2021-07-09 15:51:31 +02:00
|
|
|
stream_settings_ui.launch(section);
|
2018-12-06 20:03:18 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-08-21 16:34:56 +02:00
|
|
|
if (base === "groups") {
|
|
|
|
user_groups_settings_ui.launch();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-12-06 20:03:18 +01:00
|
|
|
if (base === "drafts") {
|
2018-12-01 18:54:41 +01:00
|
|
|
drafts.launch();
|
2018-12-06 20:03:18 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
if (base === "settings") {
|
2018-12-06 20:18:56 +01:00
|
|
|
settings.launch(section);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
if (base === "organization") {
|
2018-12-06 20:18:56 +01:00
|
|
|
admin.launch(section);
|
2018-12-06 20:03:18 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (base === "invite") {
|
2018-12-01 18:54:41 +01:00
|
|
|
invite.launch();
|
2018-12-06 20:03:18 +01:00
|
|
|
return;
|
2018-12-01 18:54:41 +01:00
|
|
|
}
|
2020-04-08 13:59:56 +02:00
|
|
|
|
2020-07-02 12:07:30 +02:00
|
|
|
if (base === "keyboard-shortcuts") {
|
|
|
|
info_overlay.show("keyboard-shortcuts");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (base === "message-formatting") {
|
|
|
|
info_overlay.show("message-formatting");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (base === "search-operators") {
|
|
|
|
info_overlay.show("search-operators");
|
|
|
|
return;
|
|
|
|
}
|
2021-02-09 11:16:52 +01:00
|
|
|
|
|
|
|
if (base === "about-zulip") {
|
|
|
|
about_zulip.launch();
|
|
|
|
}
|
2018-12-01 01:08:48 +01:00
|
|
|
}
|
|
|
|
|
2018-12-04 23:06:30 +01:00
|
|
|
function hashchanged(from_reload, e) {
|
2021-05-19 05:34:35 +02:00
|
|
|
const current_hash = window.location.hash;
|
2021-03-22 16:09:12 +01:00
|
|
|
const old_hash = e && (e.oldURL ? new URL(e.oldURL).hash : browser_history.old_hash());
|
2021-11-17 13:24:17 +01:00
|
|
|
const is_hash_web_public_compatible = browser_history.update_web_public_hash(current_hash);
|
2021-03-22 16:09:12 +01:00
|
|
|
|
|
|
|
const was_internal_change = browser_history.save_old_hash();
|
|
|
|
if (was_internal_change) {
|
2020-09-24 07:50:36 +02:00
|
|
|
return undefined;
|
2018-12-04 23:06:30 +01:00
|
|
|
}
|
|
|
|
|
2021-06-28 05:08:55 +02:00
|
|
|
// TODO: Migrate the `#reload` syntax to use slashes as separators
|
|
|
|
// so that this can be part of the main switch statement.
|
|
|
|
if (window.location.hash.startsWith("#reload")) {
|
|
|
|
// We don't want to change narrow if app is undergoing reload.
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
|
2021-05-19 05:34:35 +02:00
|
|
|
if (page_params.is_spectator && !is_hash_web_public_compatible) {
|
2021-09-07 04:09:12 +02:00
|
|
|
spectators.login_to_access();
|
2021-05-19 05:34:35 +02:00
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hash_util.is_overlay_hash(current_hash)) {
|
2021-04-09 13:54:44 +02:00
|
|
|
browser_history.state.changing_hash = true;
|
2018-12-04 23:06:30 +01:00
|
|
|
do_hashchange_overlay(old_hash);
|
2021-04-09 13:54:44 +02:00
|
|
|
browser_history.state.changing_hash = false;
|
2020-09-24 07:50:36 +02:00
|
|
|
return undefined;
|
2018-12-04 23:06:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// We are changing to a "main screen" view.
|
|
|
|
overlays.close_for_hash_change();
|
2021-04-09 13:53:45 +02:00
|
|
|
browser_history.state.changing_hash = true;
|
2019-11-02 00:06:25 +01:00
|
|
|
const ret = do_hashchange_normal(from_reload);
|
2021-04-09 13:53:45 +02:00
|
|
|
browser_history.state.changing_hash = false;
|
2018-12-04 23:06:30 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2021-02-28 01:07:47 +01:00
|
|
|
export function initialize() {
|
2020-07-15 01:29:15 +02:00
|
|
|
$(window).on("hashchange", (e) => {
|
2019-07-09 04:30:51 +02:00
|
|
|
hashchanged(false, e.originalEvent);
|
2016-10-23 07:07:09 +02:00
|
|
|
});
|
2014-02-12 20:03:05 +01:00
|
|
|
hashchanged(true);
|
2021-02-28 01:07:47 +01:00
|
|
|
}
|