rafmacalaba commited on
Commit
5c1c0e8
·
1 Parent(s): 0880d65

fix: don't fetch docs until annotatorName is set

Browse files

Prevents race condition where docs are fetched with no user filter
before the HF cookie is read, causing a flash of all documents.

Files changed (1) hide show
  1. app/page.js +4 -3
app/page.js CHANGED
@@ -51,10 +51,11 @@ export default function Home() {
51
 
52
  // Load documents (re-fetches when annotatorName changes to get user-specific assignment)
53
  useEffect(() => {
 
 
 
54
  setLoading(true);
55
- const url = annotatorName
56
- ? `/api/documents?user=${encodeURIComponent(annotatorName)}`
57
- : '/api/documents';
58
 
59
  fetch(url)
60
  .then(res => res.json())
 
51
 
52
  // Load documents (re-fetches when annotatorName changes to get user-specific assignment)
53
  useEffect(() => {
54
+ // Don't fetch until we know who the user is — avoids showing all docs briefly
55
+ if (!annotatorName) return;
56
+
57
  setLoading(true);
58
+ const url = `/api/documents?user=${encodeURIComponent(annotatorName)}`;
 
 
59
 
60
  fetch(url)
61
  .then(res => res.json())