Commit 6eaaf7c
committed
perf: cut ~800ms off dashboard first paint
Three changes that target the auth waterfall before bootstrap fires:
1. auth-provider: drop the unconditional currentUser.reload() and
stop forcing getIdToken(true) on every onAuthStateChanged. Both
were extra round-trips to Firebase on every page load. The cached
token is still server-verifiable and emailVerified is persisted
in the SDK's local store. The "I changed something, pick it up"
path (refreshUser) still passes forceRefresh: true so the email-
verification flow keeps working.
2. auth-provider: expose firebaseUser on the context immediately
when onAuthStateChanged fires — before /api/user/profile is
even called. Consumers can now key off that to start their own
authenticated fetches in parallel with profile.
3. dashboard-container: key the bootstrap effect on firebaseUser?.uid
instead of user?.uid. Bootstrap now fires the moment Firebase
confirms a session, in parallel with the auth-provider's profile
fetch. The dashboard's render gate still waits on both (user +
isLoading), so wall-clock load = max(profile, bootstrap) instead
of profile + bootstrap. Drops the redirect-to-login gate to only
fire after authLoading actually completes, so the parallel kick-
off doesn't accidentally bounce the user mid-init.
Combined savings on dashboard cold load: ~600-1000ms depending on
Firebase / network. No change to security posture — every API call
still verifies the ID token server-side.1 parent d0785b9 commit 6eaaf7c
2 files changed
Lines changed: 51 additions & 23 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
36 | 40 | | |
37 | 41 | | |
38 | 42 | | |
| |||
45 | 49 | | |
46 | 50 | | |
47 | 51 | | |
| 52 | + | |
48 | 53 | | |
49 | 54 | | |
50 | 55 | | |
| |||
59 | 64 | | |
60 | 65 | | |
61 | 66 | | |
| 67 | + | |
62 | 68 | | |
63 | 69 | | |
64 | 70 | | |
65 | 71 | | |
66 | | - | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
67 | 84 | | |
68 | | - | |
69 | | - | |
70 | | - | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
71 | 89 | | |
72 | 90 | | |
73 | 91 | | |
| |||
112 | 130 | | |
113 | 131 | | |
114 | 132 | | |
115 | | - | |
116 | | - | |
117 | | - | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
118 | 140 | | |
119 | 141 | | |
120 | 142 | | |
| |||
248 | 270 | | |
249 | 271 | | |
250 | 272 | | |
251 | | - | |
252 | | - | |
253 | 273 | | |
254 | | - | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
255 | 278 | | |
256 | 279 | | |
257 | 280 | | |
| |||
292 | 315 | | |
293 | 316 | | |
294 | 317 | | |
| 318 | + | |
295 | 319 | | |
296 | 320 | | |
297 | 321 | | |
| |||
300 | 324 | | |
301 | 325 | | |
302 | 326 | | |
303 | | - | |
| 327 | + | |
304 | 328 | | |
305 | 329 | | |
306 | 330 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
253 | 253 | | |
254 | 254 | | |
255 | 255 | | |
256 | | - | |
| 256 | + | |
257 | 257 | | |
258 | 258 | | |
259 | 259 | | |
| |||
351 | 351 | | |
352 | 352 | | |
353 | 353 | | |
354 | | - | |
355 | | - | |
356 | | - | |
357 | | - | |
358 | | - | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
359 | 363 | | |
360 | 364 | | |
361 | 365 | | |
| |||
447 | 451 | | |
448 | 452 | | |
449 | 453 | | |
450 | | - | |
451 | | - | |
452 | | - | |
453 | | - | |
454 | | - | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
455 | 459 | | |
456 | | - | |
| 460 | + | |
457 | 461 | | |
458 | 462 | | |
459 | 463 | | |
| |||
0 commit comments