[READ-ONLY] Mirror of https://github.com/flo-bit/atmo-tools. atmo.tools
0

Configure Feed

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

fix cursor issues

+14 -3
+14 -3
src/lib/search-state.svelte.ts
··· 205 205 206 206 if (existing) { 207 207 if (existing.sources.includes(source)) { 208 - // Already indexed for this source — flush updates and stop 208 + // Already indexed for this source — flush updates and stop. 209 + // Use the last record's rkey as cursor so the tail resumes past this point. 210 + const lastRecord = data.records[j]; 211 + const stopCursor = lastRecord?.uri?.split('/').pop() ?? data.cursor; 209 212 if (toUpdate.length > 0) await db.posts.bulkPut(toUpdate); 210 - return { cursor: data.cursor, done: true }; 213 + return { cursor: stopCursor, done: true }; 211 214 } 212 215 // Post exists from another source — queue source tag update 213 216 toUpdate.push({ ...existing, sources: [...existing.sources, source], fetchedAt: now }); ··· 222 225 if (toUpdate.length > 0) await db.posts.bulkPut(toUpdate); 223 226 224 227 const nextCursor = data.records.length > 0 ? data.cursor : undefined; 228 + // Detect stalled cursor — if the API returns the same cursor we sent, stop. 229 + if (nextCursor && nextCursor === cursor) { 230 + return { cursor: nextCursor, done: true }; 231 + } 225 232 return { cursor: nextCursor, done: !nextCursor }; 226 233 } 227 234 ··· 382 389 if (existing.sources.includes(source)) { 383 390 // Already indexed for this source — flush and stop 384 391 if (toPut.length > 0) await db.posts.bulkPut(toPut); 385 - return { cursor: data.cursor, done: true }; 392 + return { cursor: data.cursor ?? cursor, done: true }; 386 393 } 387 394 // Exists from another source — queue tag update 388 395 toPut.push({ ...existing, sources: [...existing.sources, source], fetchedAt: now }); ··· 401 408 if (toPut.length > 0) await db.posts.bulkPut(toPut); 402 409 403 410 const nextCursor = data.bookmarks.length > 0 ? data.cursor : undefined; 411 + // Detect stalled cursor — if the API returns the same cursor we sent, stop. 412 + if (nextCursor && nextCursor === cursor) { 413 + return { cursor: nextCursor, done: true }; 414 + } 404 415 return { cursor: nextCursor, done: !nextCursor }; 405 416 } 406 417