Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 179d2a7

Browse files
authored
Add theme data to EC widget Url (#12279)
* Add theme data to EC widget url Signed-off-by: Timo K <[email protected]> * test theme Signed-off-by: Timo K <[email protected]> --------- Signed-off-by: Timo K <[email protected]>
1 parent 1403cd8 commit 179d2a7

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/models/Call.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ export class ElementCall extends Call {
688688
baseUrl: client.baseUrl,
689689
lang: getCurrentLanguage().replace("_", "-"),
690690
fontScale: (FontWatcher.getRootFontSize() / FontWatcher.getBrowserDefaultFontSize()).toString(),
691-
691+
theme: "$org.matrix.msc2873.client_theme",
692692
analyticsID,
693693
});
694694

test/stores/widgets/StopGapWidget-test.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { ElementWidgetActions } from "../../../src/stores/widgets/ElementWidgetA
2727
import { VoiceBroadcastInfoEventType, VoiceBroadcastRecording } from "../../../src/voice-broadcast";
2828
import { SdkContextClass } from "../../../src/contexts/SDKContext";
2929
import ActiveWidgetStore from "../../../src/stores/ActiveWidgetStore";
30+
import SettingsStore from "../../../src/settings/SettingsStore";
3031

3132
jest.mock("matrix-widget-api/lib/ClientWidgetApi");
3233

@@ -44,7 +45,7 @@ describe("StopGapWidget", () => {
4445
id: "test",
4546
creatorUserId: "@alice:example.org",
4647
type: "example",
47-
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",
48+
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",
4849
roomId: "!1:example.org",
4950
},
5051
room: mkRoom(client, "!1:example.org"),
@@ -63,9 +64,15 @@ describe("StopGapWidget", () => {
6364
});
6465

6566
it("should replace parameters in widget url template", () => {
67+
const originGetValue = SettingsStore.getValue;
68+
const spy = jest.spyOn(SettingsStore, "getValue").mockImplementation((setting) => {
69+
if (setting === "theme") return "my-theme-for-testing";
70+
return originGetValue(setting);
71+
});
6672
expect(widget.embedUrl).toBe(
67-
"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",
73+
"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",
6874
);
75+
spy.mockClear();
6976
});
7077

7178
it("feeds incoming to-device messages to the widget", async () => {

0 commit comments

Comments
 (0)