channel: Use base_page_params.

Fixes errors on /devtools/integrations/ and /emails/.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2024-02-27 17:02:40 -08:00 committed by Anders Kaseorg
parent a200c966e3
commit 664fdf1a92
3 changed files with 7 additions and 4 deletions

View File

@ -2,8 +2,8 @@ import * as Sentry from "@sentry/browser";
import $ from "jquery";
import _ from "lodash";
import {page_params} from "./base_page_params";
import * as blueslip from "./blueslip";
import {page_params} from "./page_params";
import * as reload_state from "./reload_state";
import {normalize_path, shouldCreateSpanForRequest} from "./sentry";
import * as spectators from "./spectators";
@ -106,7 +106,7 @@ function call(args: AjaxRequestHandlerOptions): JQuery.jqXHR<unknown> | undefine
return;
}
if (page_params.is_spectator) {
if (page_params.page_type === "home" && page_params.is_spectator) {
// In theory, the spectator implementation should be
// designed to prevent accessing widgets that would
// make network requests not available to spectators.
@ -115,7 +115,7 @@ function call(args: AjaxRequestHandlerOptions): JQuery.jqXHR<unknown> | undefine
// prefer the user experience of offering the
// login_to_access widget over reloading the page.
spectators.login_to_access();
} else {
} else if (page_params.page_type === "home") {
// We got logged out somehow, perhaps from another window
// changing the user's password, or a session timeout. We
// could display an error message, but jumping right to

View File

@ -9,9 +9,9 @@ import $ from "jquery";
import render_login_to_access_modal from "../templates/login_to_access.hbs";
import {page_params} from "./base_page_params";
import * as browser_history from "./browser_history";
import * as modals from "./modals";
import {page_params} from "./page_params";
import {realm} from "./state_data";
export function current_hash_as_next(): string {

View File

@ -238,6 +238,7 @@ test("authentication_error_401_is_spectator", () => {
// is_spectator = true
check_ajax_options(options) {
page_params.page_type = "home";
page_params.is_spectator = true;
options.simulate_error();
@ -258,6 +259,7 @@ test("authentication_error_401_password_change_in_progress", () => {
// is_spectator = true
// password_change_in_progress = true
check_ajax_options(options) {
page_params.page_type = "home";
page_params.is_spectator = true;
channel.set_password_change_in_progress(true);
@ -280,6 +282,7 @@ test("authentication_error_401_not_spectator", () => {
// is_spectator = false
check_ajax_options(options) {
page_params.page_type = "home";
page_params.is_spectator = false;
options.simulate_error();