Add theme data to EC widget Url (#12279)

* Add theme data to EC widget url

Signed-off-by: Timo K <toger5@hotmail.de>

* test theme

Signed-off-by: Timo K <toger5@hotmail.de>

---------

Signed-off-by: Timo K <toger5@hotmail.de>
This commit is contained in:
Timo 2024-02-26 18:21:52 +01:00 committed by GitHub
parent 1403cd851a
commit 179d2a767e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 3 deletions

View file

@ -688,7 +688,7 @@ export class ElementCall extends Call {
baseUrl: client.baseUrl, baseUrl: client.baseUrl,
lang: getCurrentLanguage().replace("_", "-"), lang: getCurrentLanguage().replace("_", "-"),
fontScale: (FontWatcher.getRootFontSize() / FontWatcher.getBrowserDefaultFontSize()).toString(), fontScale: (FontWatcher.getRootFontSize() / FontWatcher.getBrowserDefaultFontSize()).toString(),
theme: "$org.matrix.msc2873.client_theme",
analyticsID, analyticsID,
}); });

View file

@ -27,6 +27,7 @@ import { ElementWidgetActions } from "../../../src/stores/widgets/ElementWidgetA
import { VoiceBroadcastInfoEventType, VoiceBroadcastRecording } from "../../../src/voice-broadcast"; import { VoiceBroadcastInfoEventType, VoiceBroadcastRecording } from "../../../src/voice-broadcast";
import { SdkContextClass } from "../../../src/contexts/SDKContext"; import { SdkContextClass } from "../../../src/contexts/SDKContext";
import ActiveWidgetStore from "../../../src/stores/ActiveWidgetStore"; import ActiveWidgetStore from "../../../src/stores/ActiveWidgetStore";
import SettingsStore from "../../../src/settings/SettingsStore";
jest.mock("matrix-widget-api/lib/ClientWidgetApi"); jest.mock("matrix-widget-api/lib/ClientWidgetApi");
@ -44,7 +45,7 @@ describe("StopGapWidget", () => {
id: "test", id: "test",
creatorUserId: "@alice:example.org", creatorUserId: "@alice:example.org",
type: "example", type: "example",
url: "https://example.org?user-id=$matrix_user_id&device-id=$org.matrix.msc3819.matrix_device_id&base-url=$org.matrix.msc4039.matrix_base_url", url: "https://example.org?user-id=$matrix_user_id&device-id=$org.matrix.msc3819.matrix_device_id&base-url=$org.matrix.msc4039.matrix_base_url&theme=$org.matrix.msc2873.client_theme",
roomId: "!1:example.org", roomId: "!1:example.org",
}, },
room: mkRoom(client, "!1:example.org"), room: mkRoom(client, "!1:example.org"),
@ -63,9 +64,15 @@ describe("StopGapWidget", () => {
}); });
it("should replace parameters in widget url template", () => { it("should replace parameters in widget url template", () => {
const originGetValue = SettingsStore.getValue;
const spy = jest.spyOn(SettingsStore, "getValue").mockImplementation((setting) => {
if (setting === "theme") return "my-theme-for-testing";
return originGetValue(setting);
});
expect(widget.embedUrl).toBe( expect(widget.embedUrl).toBe(
"https://example.org/?user-id=%40userId%3Amatrix.org&device-id=ABCDEFGHI&base-url=https%3A%2F%2Fmatrix-client.matrix.org&widgetId=test&parentUrl=http%3A%2F%2Flocalhost%2F", "https://example.org/?user-id=%40userId%3Amatrix.org&device-id=ABCDEFGHI&base-url=https%3A%2F%2Fmatrix-client.matrix.org&theme=my-theme-for-testing&widgetId=test&parentUrl=http%3A%2F%2Flocalhost%2F",
); );
spy.mockClear();
}); });
it("feeds incoming to-device messages to the widget", async () => { it("feeds incoming to-device messages to the widget", async () => {