move sendContentLoaded (useTheme -> App)

Signed-off-by: Timo K <toger5@hotmail.de>
This commit is contained in:
Timo K
2024-02-28 21:07:50 +01:00
parent cce89eb880
commit 204d24c300
2 changed files with 2 additions and 6 deletions

View File

@@ -72,7 +72,9 @@ export const App: FC<AppProps> = ({ history }) => {
const [loaded, setLoaded] = useState(false);
useEffect(() => {
Initializer.init()?.then(() => {
if (loaded) return;
setLoaded(true);
widget?.api.sendContentLoaded();
});
});

View File

@@ -17,11 +17,9 @@ limitations under the License.
import { useLayoutEffect, useRef } from "react";
import { useUrlParams } from "./UrlParams";
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".
@@ -39,9 +37,5 @@ export const useTheme = (): void => {
previousTheme.current = themeString;
}
document.body.classList.remove("nodisplay");
if (!contentLoadedSent.current) {
widget?.api.sendContentLoaded();
contentLoadedSent.current = true;
}
}, [previousTheme, themeName]);
};