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.

channel: Use base_page_params.

Anders Kaseorg664fdf1a9290
diff --git a/web/src/channel.ts b/web/src/channel.ts
index 40e4a70c2f0..6e4d9e34057 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<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
diff --git a/web/src/spectators.ts b/web/src/spectators.ts
index 336f390d869..2776c72407e 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 87e95c9e5aa..1c35740c3ff 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();