Fix: robust token/session handling, no client-side job data caching, improved reauth flow
This commit is contained in:
+2
-24
@@ -414,35 +414,13 @@
|
||||
clearJobsCache('Loading…');
|
||||
const startTime = performance.now();
|
||||
try{
|
||||
// Check client-side cache first (sessionStorage)
|
||||
const cachedData = sessionStorage.getItem('jobsCache');
|
||||
const cacheTime = sessionStorage.getItem('jobsCacheTime');
|
||||
const cacheAge = cacheTime ? Date.now() - parseInt(cacheTime) : Infinity;
|
||||
|
||||
// Use client cache if less than 5 minutes old
|
||||
if (cachedData && cacheAge < 300000) {
|
||||
const data = JSON.parse(cachedData);
|
||||
jobsCache.push(...data);
|
||||
const loadTime = Math.round(performance.now() - startTime);
|
||||
console.log(`✓ Loaded ${data.length} jobs from CLIENT CACHE in ${loadTime}ms`);
|
||||
progressBar.style.width='95%';
|
||||
applyFiltersAndRender();
|
||||
finishProgress();
|
||||
return;
|
||||
}
|
||||
|
||||
// Use single cached endpoint that returns all jobs at once
|
||||
// All job data should be fetched from backend/Valkey cache
|
||||
const url = `/api/jobs-all`;
|
||||
const res = await fetchNoCache(url);
|
||||
if(!res.ok) throw new Error(`Fetch failed: ${res.status}`);
|
||||
const data = await res.json();
|
||||
const items = data.items || [];
|
||||
jobsCache.push(...items);
|
||||
|
||||
// Store in client-side cache
|
||||
sessionStorage.setItem('jobsCache', JSON.stringify(items));
|
||||
sessionStorage.setItem('jobsCacheTime', Date.now().toString());
|
||||
|
||||
const loadTime = Math.round(performance.now() - startTime);
|
||||
console.log(`✓ Loaded ${items.length} jobs from API in ${loadTime}ms`);
|
||||
|
||||
@@ -450,7 +428,7 @@
|
||||
progressBar.style.width='95%';
|
||||
const renderStart = performance.now();
|
||||
applyFiltersAndRender();
|
||||
const renderTime = Math.round(performance.now() - renderStart);
|
||||
const renderTime = Math.round(performance.now() - startTime);
|
||||
console.log(`✓ Rendered jobs in ${renderTime}ms (Total: ${Math.round(performance.now() - startTime)}ms)`);
|
||||
finishProgress();
|
||||
}catch(err){ finishProgress(); alert('Failed to fetch jobs: '+err.message); console.error(err);}
|
||||
|
||||
Reference in New Issue
Block a user