Skip to content

Commit 2d1ea3b

Browse files
committed
Fix more PR comments
1 parent 1945940 commit 2d1ea3b

2 files changed

Lines changed: 11 additions & 10 deletions

File tree

src/lib/tour/onboarding-state.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,10 @@ export function hasSeenWelcome(): boolean {
4444

4545
export function markWelcomed(): void {
4646
try {
47-
cookieStore
48-
.set({
49-
name: WELCOME_COOKIE_NAME,
50-
value: 'true',
51-
path: '/',
52-
expires: WELCOME_COOKIE_EXPIRES.getTime(),
53-
sameSite: 'lax',
54-
})
55-
.catch(() => {});
47+
// Synchronous document.cookie write. The async cookieStore API would also work
48+
// (Chrome 87+, Firefox 140+, Safari 18.4+), but for a one-shot write it buys
49+
// nothing and drops older browsers, so the plain string write is preferred.
50+
document.cookie = `${WELCOME_COOKIE_NAME}=true; path=/; expires=${WELCOME_COOKIE_EXPIRES.toUTCString()}; SameSite=Lax`;
5651
} catch {
5752
// ignore
5853
}

src/routes/+layout.server.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { SIDEBAR_COOKIE_NAME } from '$lib/components/ui/sidebar/constants';
2-
import { isWelcomeSunset, WELCOME_COOKIE_NAME } from '$lib/tour/onboarding-state';
2+
import { isOnboardingDisabled, isWelcomeSunset, WELCOME_COOKIE_NAME } from '$lib/tour/onboarding-state';
33
import { isTruthy } from '$lib/utils/parse';
44
import type { LayoutServerLoad } from './$types';
55

@@ -9,6 +9,12 @@ export const load: LayoutServerLoad = ({ cookies }) => {
99
// state and we avoid a collapse-then-expand flash on hydration.
1010
const sidebarOpen = cookies.get(SIDEBAR_COOKIE_NAME) === 'true';
1111

12+
// When onboarding is disabled the client unmounts the screen immediately on
13+
// hydration, so SSR-ing it just hurts LCP — skip it server-side too.
14+
if (isOnboardingDisabled()) {
15+
return { sidebarOpen, showWelcome: false };
16+
}
17+
1218
// Past the sunset date the welcome screen is retired — never SSR it, and clear
1319
// the cookie if a returning visitor still has it set.
1420
if (isWelcomeSunset()) {

0 commit comments

Comments
 (0)