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: push sync runs every boot, not just once' (#21) from fix/pds-sync-race into main

scott d9e51dd7 384ea102

+5 -12
+1 -6
src/lib/pds-push-sync.ts
··· 1 1 /** 2 2 * PDS push sync — uploads local documents missing from PDS. 3 - * Handles the case where documents existed before sync was enabled. 4 - * Called once during boot after identity is ready. 3 + * Runs on every landing page boot (idempotent — skips docs already on PDS). 5 4 */ 6 5 7 6 import { listPdsDocuments, saveDocumentToPds } from './pds-documents.js'; ··· 9 8 import { isPdsReady } from './pds-setup.js'; 10 9 import { getSession } from './auth.js'; 11 10 12 - const PUSH_SYNC_KEY = 'atmos-pds-push-sync-done'; 13 - 14 11 export async function pushLocalDocuments(): Promise<number> { 15 12 if (!isPdsReady()) return 0; 16 - if (localStorage.getItem(PUSH_SYNC_KEY)) return 0; 17 13 18 14 const session = getSession(); 19 15 if (!session) return 0; ··· 36 32 } 37 33 } 38 34 39 - localStorage.setItem(PUSH_SYNC_KEY, Date.now().toString()); 40 35 return pushed; 41 36 }
+4 -6
src/lib/provider.ts
··· 256 256 import('./identity-keys.js').then(({ getIdentityKeyPair }) => { 257 257 getIdentityKeyPair().then(keyPair => { 258 258 if (!keyPair) return; 259 - import('./pds-setup.js').then(({ ensurePdsIdentity }) => { 260 - ensurePdsIdentity().then(ready => { 261 - if (!ready) return; 262 - saveDocumentToPds(session.agent, session.did, this.roomId).catch(err => { 263 - console.warn('PDS sync failed (will retry on next save):', err); 264 - }); 259 + ensurePdsIdentity().then(ready => { 260 + if (!ready) return; 261 + saveDocumentToPds(session.agent, session.did, this.roomId).catch(err => { 262 + console.warn('PDS sync failed (will retry on next save):', err); 265 263 }); 266 264 }); 267 265 });