Full document, spreadsheet, slideshow, and diagram tooling
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request 'fix: improve document list reliability on landing page' (#150) from fix/landing-page-doc-list into main

scott a0db69b4 1f5b3df7

+29 -11
+1 -1
public/sw.js
··· 8 8 * - API/WS/health: network-only (never cached) 9 9 */ 10 10 11 - const CACHE_NAME = 'tools-v1'; 11 + const CACHE_NAME = 'tools-v2'; 12 12 13 13 // Static assets to pre-cache on install 14 14 const PRECACHE_URLS = [
+6
server/index.ts
··· 210 210 app.use(compression()); 211 211 app.use(express.json({ limit: '1mb' })); 212 212 213 + // Prevent browser/proxy caching of API responses 214 + app.use('/api', (_req, res, next) => { 215 + res.set('Cache-Control', 'no-store'); 216 + next(); 217 + }); 218 + 213 219 // API routes 214 220 app.post('/api/documents', (req: Request<Record<string, string>, unknown, CreateDocumentBody>, res: Response) => { 215 221 const id = randomUUID();
+22 -10
src/landing.ts
··· 442 442 async function loadDocuments() { 443 443 await migrateLocalStorageTrash(); 444 444 445 - const [activeRes, trashRes] = await Promise.all([ 446 - fetch('/api/documents'), 447 - fetch('/api/documents/trash'), 448 - ]); 449 - const docs = await activeRes.json(); 450 - const trashed = await trashRes.json(); 445 + try { 446 + const [activeRes, trashRes] = await Promise.all([ 447 + fetch('/api/documents'), 448 + fetch('/api/documents/trash'), 449 + ]); 451 450 452 - await Promise.all([decryptDocNames(docs), decryptDocNames(trashed)]); 451 + if (!activeRes.ok || !trashRes.ok) { 452 + console.error('Failed to load documents:', activeRes.status, trashRes.status); 453 + showToast('Failed to load documents \u2014 try refreshing', 5000, true); 454 + return; 455 + } 453 456 454 - allDocs = docs; 455 - trashedDocs = trashed; 456 - renderDocuments(); 457 + const docs = await activeRes.json(); 458 + const trashed = await trashRes.json(); 459 + 460 + await Promise.all([decryptDocNames(docs), decryptDocNames(trashed)]); 461 + 462 + allDocs = docs; 463 + trashedDocs = trashed; 464 + renderDocuments(); 465 + } catch (err) { 466 + console.error('Failed to load documents:', err); 467 + showToast('Failed to load documents \u2014 try refreshing', 5000, true); 468 + } 457 469 } 458 470 459 471 function renderRecentSection(keys: Record<string, string>) {