Emit widget content loaded action after theme is set.

Signed-off-by: Timo K <toger5@hotmail.de>
This commit is contained in:
Timo K
2024-02-28 20:57:04 +01:00
parent e3ce95fe2f
commit cce89eb880
2 changed files with 7 additions and 0 deletions

View File

@@ -21,6 +21,7 @@ import { widget } from "./widget";
export const useTheme = (): void => {
const { theme: themeName } = useUrlParams();
const contentLoadedSent = useRef<boolean>(false);
const previousTheme = useRef<string | null>(document.body.classList.item(0));
useLayoutEffect(() => {
// If the url does not contain a theme props we default to "dark".
@@ -38,5 +39,9 @@ export const useTheme = (): void => {
previousTheme.current = themeString;
}
document.body.classList.remove("nodisplay");
if (!contentLoadedSent.current) {
widget?.api.sendContentLoaded();
contentLoadedSent.current = true;
}
}, [previousTheme, themeName]);
};

View File

@@ -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<MatrixClient>((resolve) => {