mirror of
https://github.com/TecharoHQ/anubis.git
synced 2026-04-08 09:38:45 +00:00
fix(js/main): move title updating from an effect to the error handler function
Signed-off-by: Xe Iaso <me@xeiaso.net>
This commit is contained in:
@@ -106,16 +106,6 @@ function App({ anubisVersion, basePrefix }: AppProps) {
|
||||
const redirectFn = useRef<(() => void) | null>(null);
|
||||
const detailsRead = useRef(false);
|
||||
|
||||
// Sync <h1 id="title"> when entering error state (it's outside the Preact tree)
|
||||
useEffect(() => {
|
||||
if (phase === "error") {
|
||||
const titleEl = document.getElementById("title");
|
||||
if (titleEl) {
|
||||
titleEl.textContent = errorTitle;
|
||||
}
|
||||
}
|
||||
}, [phase, errorTitle]);
|
||||
|
||||
// Main initialization
|
||||
useEffect(() => {
|
||||
const details = document.querySelector("details");
|
||||
@@ -132,6 +122,12 @@ function App({ anubisVersion, basePrefix }: AppProps) {
|
||||
setErrorMessage(message);
|
||||
setErrorImage(imageSrc);
|
||||
setPhase("error");
|
||||
|
||||
// sync title element (it's outside of the JSX tree)
|
||||
const titleEl = document.getElementById("title");
|
||||
if (titleEl) {
|
||||
titleEl.textContent = title;
|
||||
}
|
||||
};
|
||||
|
||||
const dependencies = [
|
||||
|
||||
Reference in New Issue
Block a user