Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The preload URL param shouldn't be used in SPA mode, so ignore it if not in widget #2832

Merged
merged 6 commits into from
Nov 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/UrlParams.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Please see LICENSE in the repository root for full details.

import { describe, expect, it } from "vitest";

import { getRoomIdentifierFromUrl } from "../src/UrlParams";
import { getRoomIdentifierFromUrl, getUrlParams } from "../src/UrlParams";

const ROOM_NAME = "roomNameHere";
const ROOM_ID = "!d45f138fsd";
Expand Down Expand Up @@ -86,4 +86,18 @@ describe("UrlParams", () => {
.roomAlias,
).toBeFalsy();
});

describe("preload", () => {
it("defaults to false", () => {
expect(getUrlParams().preload).toBe(false);
});

it("ignored in SPA mode", () => {
expect(getUrlParams("?preload=true").preload).toBe(false);
});

it("respected in widget mode", () => {
expect(getUrlParams("?preload=true&widgetId=12345").preload).toBe(true);
});
});
});
7 changes: 5 additions & 2 deletions src/UrlParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,11 @@ export const getUrlParams = (

const fontScale = parseFloat(parser.getParam("fontScale") ?? "");

const widgetId = parser.getParam("widgetId");
const isWidget = !!widgetId;

return {
widgetId: parser.getParam("widgetId"),
widgetId,
parentUrl: parser.getParam("parentUrl"),

// NB. we don't validate roomId here as we do in getRoomIdentifierFromUrl:
Expand All @@ -224,7 +227,7 @@ export const getUrlParams = (
confineToRoom:
parser.getFlagParam("confineToRoom") || parser.getFlagParam("embed"),
appPrompt: parser.getFlagParam("appPrompt", true),
preload: parser.getFlagParam("preload"),
preload: isWidget ? parser.getFlagParam("preload") : false,
hideHeader: parser.getFlagParam("hideHeader"),
showControls: parser.getFlagParam("showControls", true),
hideScreensharing: parser.getFlagParam("hideScreensharing"),
Expand Down