From 664fdf1a9290a554d900262ac10304b660b607ad Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Tue, 27 Feb 2024 17:02:40 -0800 Subject: [PATCH] channel: Use base_page_params. Fixes errors on /devtools/integrations/ and /emails/. Signed-off-by: Anders Kaseorg --- web/src/channel.ts | 6 +++--- web/src/spectators.ts | 2 +- web/tests/channel.test.js | 3 +++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/web/src/channel.ts b/web/src/channel.ts index 40e4a70c2f..6e4d9e3405 100644 --- a/web/src/channel.ts +++ b/web/src/channel.ts @@ -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 | 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 | 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 diff --git a/web/src/spectators.ts b/web/src/spectators.ts index 336f390d86..2776c72407 100644 --- a/web/src/spectators.ts +++ b/web/src/spectators.ts @@ -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 { diff --git a/web/tests/channel.test.js b/web/tests/channel.test.js index 87e95c9e5a..1c35740c3f 100644 --- a/web/tests/channel.test.js +++ b/web/tests/channel.test.js @@ -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();