Improved legal screen
This commit is contained in:
parent
76ca664298
commit
82a14f65fa
1 changed files with 65 additions and 75 deletions
|
|
@ -51,16 +51,14 @@ export default function Screen(props: { children: React.ReactNode }) {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let active = true;
|
let active = true;
|
||||||
|
|
||||||
const shouldBlockRender = userId === undefined || userId === 0;
|
|
||||||
|
|
||||||
if (shouldBlockRender) {
|
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
}
|
|
||||||
|
|
||||||
setError("");
|
setError("");
|
||||||
setErrorDescription("");
|
setErrorDescription("");
|
||||||
|
|
||||||
void load("user_id").then(async (id) => {
|
void (async () => {
|
||||||
|
try {
|
||||||
|
const id = await load("user_id");
|
||||||
if (!active) {
|
if (!active) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -68,9 +66,6 @@ export default function Screen(props: { children: React.ReactNode }) {
|
||||||
setUserId(id);
|
setUserId(id);
|
||||||
|
|
||||||
if (id === 0) {
|
if (id === 0) {
|
||||||
if (shouldBlockRender) {
|
|
||||||
setLoading(false);
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -123,32 +118,27 @@ export default function Screen(props: { children: React.ReactNode }) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
acceptPP(loadedAcceptedPP);
|
acceptPP(
|
||||||
acceptTOS(loadedAcceptedTOS);
|
loadedAcceptedPP &&
|
||||||
|
!!currentLocalDocs &&
|
||||||
if (
|
currentLocalDocs.pp.hash === safeCurrent.data.pp.hash,
|
||||||
!currentLocalDocs ||
|
);
|
||||||
currentLocalDocs.pp.hash !== safeCurrent.data.pp.hash
|
acceptTOS(
|
||||||
) {
|
loadedAcceptedTOS &&
|
||||||
acceptPP(false);
|
!!currentLocalDocs &&
|
||||||
}
|
currentLocalDocs.tos.hash === safeCurrent.data.tos.hash,
|
||||||
|
);
|
||||||
if (
|
} finally {
|
||||||
!currentLocalDocs ||
|
if (active) {
|
||||||
currentLocalDocs.tos.hash !== safeCurrent.data.tos.hash
|
|
||||||
) {
|
|
||||||
acceptTOS(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (shouldBlockRender) {
|
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
active = false;
|
active = false;
|
||||||
};
|
};
|
||||||
}, [load, location.pathname, userId]);
|
}, [load, location.pathname]);
|
||||||
|
|
||||||
if (error !== "" && errorDescription !== "") {
|
if (error !== "" && errorDescription !== "") {
|
||||||
return <ErrorScreen error={error} description={errorDescription} />;
|
return <ErrorScreen error={error} description={errorDescription} />;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue