-
-
-
+ {!hideHeader && }
diff --git a/src/auth/useInteractiveRegistration.ts b/src/auth/useInteractiveRegistration.ts
index 521496d9..135d1fac 100644
--- a/src/auth/useInteractiveRegistration.ts
+++ b/src/auth/useInteractiveRegistration.ts
@@ -50,6 +50,7 @@ export const useInteractiveRegistration = (): {
useEffect(() => {
if (widget) return;
+ // An empty registerRequest is used to get the privacy policy and recaptcha key.
authClient.current!.registerRequest({}).catch((error) => {
setPrivacyPolicyUrl(
error.data?.params["m.login.terms"]?.policies?.privacy_policy?.en?.url,
diff --git a/src/index.css b/src/index.css
index 90794ddc..22af0a28 100644
--- a/src/index.css
+++ b/src/index.css
@@ -157,6 +157,10 @@ body {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
+/* We use this to not render the page at all until we know the theme.*/
+.no-theme {
+ opacity: 0;
+}
html,
body,
diff --git a/src/useTheme.ts b/src/useTheme.ts
index 99a7e9cd..50f07ff4 100644
--- a/src/useTheme.ts
+++ b/src/useTheme.ts
@@ -22,10 +22,9 @@ export const useTheme = (): void => {
const { theme: themeName } = useUrlParams();
const previousTheme = useRef(document.body.classList.item(0));
useLayoutEffect(() => {
- // Don't update the current theme if the url does not contain a theme prop.
- if (!themeName) return;
- const theme = themeName.includes("light") ? "light" : "dark";
- const themeHighContrast = themeName.includes("high-contrast") ? "-hc" : "";
+ // If the url does not contain a theme props we default to "dark".
+ const theme = themeName?.includes("light") ? "light" : "dark";
+ const themeHighContrast = themeName?.includes("high-contrast") ? "-hc" : "";
const themeString = "cpd-theme-" + theme + themeHighContrast;
if (themeString !== previousTheme.current) {
document.body.classList.remove(
@@ -37,5 +36,6 @@ export const useTheme = (): void => {
document.body.classList.add(themeString);
previousTheme.current = themeString;
}
+ document.body.classList.remove("no-theme");
}, [previousTheme, themeName]);
};
diff --git a/src/widget.ts b/src/widget.ts
index 1ca6a2e3..32ab780e 100644
--- a/src/widget.ts
+++ b/src/widget.ts
@@ -158,6 +158,8 @@ export const widget = ((): WidgetHelpers | null => {
useE2eForGroupCall: e2eEnabled,
fallbackICEServerAllowed: allowIceFallback,
},
+ // ContentLoaded event will be sent as soon as the theme is set (see useTheme.ts)
+ false,
);
const clientPromise = new Promise((resolve) => {