Improved legal screen

This commit is contained in:
Alois 2026-04-03 00:45:36 +02:00
commit 82a14f65fa

View file

@ -51,16 +51,14 @@ export default function Screen(props: { children: React.ReactNode }) {
useEffect(() => {
let active = true;
const shouldBlockRender = userId === undefined || userId === 0;
if (shouldBlockRender) {
setLoading(true);
}
setError("");
setErrorDescription("");
void load("user_id").then(async (id) => {
void (async () => {
try {
const id = await load("user_id");
if (!active) {
return;
}
@ -68,9 +66,6 @@ export default function Screen(props: { children: React.ReactNode }) {
setUserId(id);
if (id === 0) {
if (shouldBlockRender) {
setLoading(false);
}
return;
}
@ -123,32 +118,27 @@ export default function Screen(props: { children: React.ReactNode }) {
return;
}
acceptPP(loadedAcceptedPP);
acceptTOS(loadedAcceptedTOS);
if (
!currentLocalDocs ||
currentLocalDocs.pp.hash !== safeCurrent.data.pp.hash
) {
acceptPP(false);
}
if (
!currentLocalDocs ||
currentLocalDocs.tos.hash !== safeCurrent.data.tos.hash
) {
acceptTOS(false);
}
if (shouldBlockRender) {
acceptPP(
loadedAcceptedPP &&
!!currentLocalDocs &&
currentLocalDocs.pp.hash === safeCurrent.data.pp.hash,
);
acceptTOS(
loadedAcceptedTOS &&
!!currentLocalDocs &&
currentLocalDocs.tos.hash === safeCurrent.data.tos.hash,
);
} finally {
if (active) {
setLoading(false);
}
});
}
})();
return () => {
active = false;
};
}, [load, location.pathname, userId]);
}, [load, location.pathname]);
if (error !== "" && errorDescription !== "") {
return <ErrorScreen error={error} description={errorDescription} />;