aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-10-13 04:16:14 +0000
committerAdam Soltys <[email protected]>2026-10-13 04:16:14 +0000
commitf8dedaec828cecb02412139a7653df6b5c94dbe8 (patch)
tree577f5c2792e74985db7ad9ceafce3d9f99eba370 /src
parentb01ec800019bc0ac74926a4366f045b71bd7c29b (diff)
downloadcoinosv3-f8dedaec828cecb02412139a7653df6b5c94dbe8.tar.gz
coinosv3-f8dedaec828cecb02412139a7653df6b5c94dbe8.zip
Feed pager: nearing the last slide pages the feed on, so the pictures and clips keep coming. Adam swiped to the last picture of a pager opened from the feed and it simply ended: that pager walks the feed's own posts, which page in ten at a time as the feed is scrolled, and swiping isn't scrolling — its "near the end" ask went to the media grid's crawl, which this pager doesn't read. Now, with three slides or fewer past the one on screen (on arrival, and on the pager's 1.5 s tick if a page came back empty or the feed was busy), the feed pages on — the posts it holds, then older ones from the relays (loadOlderFeed) — and the pager grows, several pages in a row when those posts carry nothing to show, until it is more than three ahead or the feed is at its end. tools/feed-pager-ahead-test.js: 26 pictures across 41 posts with 15 words-only posts in the middle and the older ones only on a stand-in relay (the feed's cache keeps 30); stepping through reaches every picture, in the feed's order.
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KPw21NEpWeTGu6swVASmBt
Diffstat (limited to 'src')
-rw-r--r--src/features/messages.js29
1 files changed, 26 insertions, 3 deletions
diff --git a/src/features/messages.js b/src/features/messages.js
index 648f22d..eb55d88 100644
--- a/src/features/messages.js
+++ b/src/features/messages.js
@@ -12143,8 +12143,8 @@ export function messagesFeature(ctx) {
playSlide(e.target);
pagerCounts(e.target);
// near the end: ask the feed for more, the pager picks them up
- const slides = scroller.children;
- if ([...slides].indexOf(e.target) >= slides.length - 3) crawlMedia().catch(() => {});
+ if (pager.fromFeed) pagerFeedAhead();
+ else { const slides = scroller.children; if ([...slides].indexOf(e.target) >= slides.length - 3) crawlMedia().catch(() => {}); }
}
}, { root: scroller, threshold: [0.6] });
growPager();
@@ -12162,7 +12162,30 @@ export function messagesFeature(ctx) {
pager.onResize = () => { if (pager && pager.cur) pager.scroller.scrollTop = pager.cur.offsetTop; };
window.addEventListener('resize', pager.onResize);
// new posts land in the feed while the pager is open; counts move
- pager.tick = setInterval(() => { if (pager) { growPager(); if (el.classList.contains('show')) pagerCounts(pager.cur); } }, 1500);
+ pager.tick = setInterval(() => { if (pager) { growPager(); pagerFeedAhead(); if (el.classList.contains('show')) pagerCounts(pager.cur); } }, 1500);
+ }
+ // A pager opened from the feed walks the feed's own posts, which page in
+ // ten at a time as the feed is scrolled. Swiping is the scrolling here:
+ // with only a few slides left past the one on screen, the feed pages on
+ // (the posts it holds, then older ones from the relays) until there are
+ // more — several pages if those posts carry none. A page that brings
+ // nothing (the feed busy, or at its end) stops it; the tick tries again.
+ const PAGER_AHEAD = 3;
+ let pagerFeeding = false;
+ async function pagerFeedAhead() {
+ if (pagerFeeding || !pager || !pager.fromFeed) return;
+ pagerFeeding = true;
+ try {
+ const c = feedNow();
+ for (let pages = 0; pages < 8 && pager && pager.fromFeed; pages++) {
+ const slides = [...pager.scroller.children];
+ if (slides.length - 1 - slides.indexOf(pager.cur) > PAGER_AHEAD) break;
+ const shown = c.shown, held = c.notes.length;
+ await loadOlderFeed();
+ growPager();
+ if (c.shown === shown && c.notes.length === held) break;
+ }
+ } catch {} finally { pagerFeeding = false; }
}
// Slides for feed items the pager doesn't have yet, appended (never
// inserted above the one on screen).