No browser storage for referrals; the birth chart opens at the drawn chart
The share page stores nothing in the browser any more: the shared link that brought a visitor travels in its login link (/belepes?ref=...) to the Google, Apple and password sign-up. The backend counts the same visitor of a link once in half an hour, instead of a sessionStorage flag. The public birth chart scrolls to the drawn chart after a calculation and when coming back to the page. Tabs scrolled to themselves on every re-render of their parent when the address had a tab (#bolygok); they now react only to the tab ids and hash changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -172,6 +172,8 @@ export function PublicChart() {
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [result, setResult] = useState<Saved | null>(null);
|
||||
const [stored, setStored] = useState(false);
|
||||
/** After a calculation (smooth) or on coming back (at once): show the drawn chart. */
|
||||
const [reveal, setReveal] = useState<ScrollBehavior | null>(null);
|
||||
const minuteRef = useRef<HTMLInputElement>(null);
|
||||
const resultRef = useRef<HTMLDivElement>(null);
|
||||
const today = useMemo(() => new Date().toISOString().slice(0, 10), []);
|
||||
@@ -206,9 +208,19 @@ export function PublicChart() {
|
||||
if (saved?.result?.chart && saved.birth?.date) {
|
||||
setResult(saved);
|
||||
setStored(true);
|
||||
setReveal("instant");
|
||||
}
|
||||
}, []);
|
||||
|
||||
// Scrolls to the drawn chart, once it is on the page. An old tab in the
|
||||
// address (#bolygok) would pull the page down to the tables instead.
|
||||
useEffect(() => {
|
||||
if (!reveal || !result) return;
|
||||
if (window.location.hash) history.replaceState(null, "", window.location.pathname + window.location.search);
|
||||
resultRef.current?.scrollIntoView({ behavior: reveal, block: "start" });
|
||||
setReveal(null);
|
||||
}, [reveal, result]);
|
||||
|
||||
/** Forgets the birth data and the chart in this browser. */
|
||||
function clear() {
|
||||
try {
|
||||
@@ -262,12 +274,7 @@ export function PublicChart() {
|
||||
} catch {
|
||||
// storage blocked or full: the chart is still shown
|
||||
}
|
||||
requestAnimationFrame(() =>
|
||||
resultRef.current?.scrollIntoView({
|
||||
behavior: "smooth",
|
||||
block: "start",
|
||||
}),
|
||||
);
|
||||
setReveal("smooth");
|
||||
} catch (err) {
|
||||
if (err instanceof ApiError && err.code === "ambiguous_local_time") {
|
||||
setAmbiguous(true);
|
||||
|
||||
Reference in New Issue
Block a user