mirror of
https://github.com/vector-im/element-call.git
synced 2026-09-01 21:25:18 +00:00
move sendContentLoaded (useTheme -> App)
Signed-off-by: Timo K <toger5@hotmail.de>
This commit is contained in:
@@ -72,7 +72,9 @@ export const App: FC<AppProps> = ({ history }) => {
|
|||||||
const [loaded, setLoaded] = useState(false);
|
const [loaded, setLoaded] = useState(false);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
Initializer.init()?.then(() => {
|
Initializer.init()?.then(() => {
|
||||||
|
if (loaded) return;
|
||||||
setLoaded(true);
|
setLoaded(true);
|
||||||
|
widget?.api.sendContentLoaded();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -17,11 +17,9 @@ limitations under the License.
|
|||||||
import { useLayoutEffect, useRef } from "react";
|
import { useLayoutEffect, useRef } from "react";
|
||||||
|
|
||||||
import { useUrlParams } from "./UrlParams";
|
import { useUrlParams } from "./UrlParams";
|
||||||
import { widget } from "./widget";
|
|
||||||
|
|
||||||
export const useTheme = (): void => {
|
export const useTheme = (): void => {
|
||||||
const { theme: themeName } = useUrlParams();
|
const { theme: themeName } = useUrlParams();
|
||||||
const contentLoadedSent = useRef<boolean>(false);
|
|
||||||
const previousTheme = useRef<string | null>(document.body.classList.item(0));
|
const previousTheme = useRef<string | null>(document.body.classList.item(0));
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
// If the url does not contain a theme props we default to "dark".
|
// If the url does not contain a theme props we default to "dark".
|
||||||
@@ -39,9 +37,5 @@ export const useTheme = (): void => {
|
|||||||
previousTheme.current = themeString;
|
previousTheme.current = themeString;
|
||||||
}
|
}
|
||||||
document.body.classList.remove("nodisplay");
|
document.body.classList.remove("nodisplay");
|
||||||
if (!contentLoadedSent.current) {
|
|
||||||
widget?.api.sendContentLoaded();
|
|
||||||
contentLoadedSent.current = true;
|
|
||||||
}
|
|
||||||
}, [previousTheme, themeName]);
|
}, [previousTheme, themeName]);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user