diff options
| author | Adam Soltys <[email protected]> | 2026-10-13 04:48:44 +0000 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-10-13 04:48:44 +0000 |
| commit | 75a5bec9490ce1e28b7c37b864f9ca9d6e621204 (patch) | |
| tree | da1d61d1cdcba4562a9895662cb80ce70da4fae9 /tools | |
| parent | b22832ffd5df280811559cdbf0455305321e160c (diff) | |
| download | coinosv3-75a5bec9490ce1e28b7c37b864f9ca9d6e621204.tar.gz coinosv3-75a5bec9490ce1e28b7c37b864f9ca9d6e621204.zip | |
Feed pager: closing it lands on the post of the slide last looked at, and the clips ahead are looked for sooner. Adam swiped to the last clip (one more loaded, slowly), closed the pager and the feed was somewhere else. Closing used glideToPost: for a row never drawn — a post the pager went on to, maybe paged in while it was open — it guesses the place from the rows' average height, draws there, and glides once to wherever the row then is; rows of very different heights (a long post, a clip finding its shape) put the guess far off, and the glide was never corrected as they settled (in the test: 325px past it; a row still undrawn after the guess sent the feed to the top). Now landOnPost jumps (the pager was covering the feed), draws, and sets the row under the top again each frame until it has sat still a moment, 2.5 s have gone, the reader touches the page, or the page is sent elsewhere. And the pager keeps more ahead before paging the feed on: six slides for clips (fewer and further between, each watched a while), four for pictures (was three). feed-pager-ahead-test: some of the words-only posts are long now, and closing on the second-last picture checks the feed sits on its post after the pictures above have loaded (fails before: row top -325).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KPw21NEpWeTGu6swVASmBt
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/feed-pager-ahead-test.js | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/tools/feed-pager-ahead-test.js b/tools/feed-pager-ahead-test.js index b5a20ba..504c122 100644 --- a/tools/feed-pager-ahead-test.js +++ b/tools/feed-pager-ahead-test.js @@ -1,5 +1,5 @@ // Swiping through the feed's pictures (or clips) in the pager is scrolling -// the feed: with three slides or fewer left past the one on screen, the +// the feed: with four slides or fewer left past the one on screen (six for clips), the // feed pages on, and the pager grows — past a run of posts with nothing to // show, too — so the reader never meets the end while there is more. // Run: bun tools/feed-pager-ahead-test.js @@ -28,7 +28,7 @@ const U = (n) => server.url.origin + '/p' + n + '.png'; const seeded = []; let ago = 100, pic = 0; for (let i = 0; i < 12; i++) seeded.push(post('picture number ' + pic + ' ' + U(pic++), ago += 60)); -for (let i = 0; i < 15; i++) seeded.push(post('just words ' + i + ' ' + 'lorem ipsum dolor sit amet. '.repeat(3), ago += 60)); +for (let i = 0; i < 15; i++) seeded.push(post('just words ' + i + ' ' + 'lorem ipsum dolor sit amet. '.repeat(i % 3 ? 3 : 90), ago += 60)); // some of them long: rows of very different heights for (let i = 0; i < 14; i++) seeded.push(post('picture number ' + pic + ' ' + U(pic++), ago += 60)); const TOTAL = pic; @@ -126,9 +126,9 @@ try { for (let step = 0; step < TOTAL + 4; step++) { const n = await slides(), i = await curIdx(); maxSlides = Math.max(maxSlides, n); - if (i >= 0 && n - 1 - i <= 3) { + if (i >= 0 && n - 1 - i <= 4) { // give the look-ahead a moment: it should get past three ahead again (or the feed's end) - await waitFor((k) => { const sc = document.querySelector('.mp-scroll'); const j = [...sc.children].findIndex((x) => Math.abs(x.offsetTop - sc.scrollTop) < 4); return sc.children.length - 1 - j > 3 || sc.children.length >= k; }, TOTAL, 6000); + await waitFor((k) => { const sc = document.querySelector('.mp-scroll'); const j = [...sc.children].findIndex((x) => Math.abs(x.offsetTop - sc.scrollTop) < 4); return sc.children.length - 1 - j > 4 || sc.children.length >= k; }, TOTAL, 6000); } const before = await curIdx(); await page.keyboard.press('ArrowDown'); @@ -139,6 +139,17 @@ try { check('every picture in the feed became reachable', (await slides()) === TOTAL, (await slides()) + ' of ' + TOTAL); check('…past fifteen posts with none', (await curName()) === 'p' + (TOTAL - 1) + '.png', await curName()); check('…in the feed\'s order', await page.evaluate((t) => [...document.querySelector('.mp-scroll').children].every((s, i) => s.getAttribute('data-k').endsWith('/p' + i + '.png')), TOTAL)); + + console.log('\n[closing lands the feed on the last picture\'s post]'); + await page.keyboard.press('ArrowUp'); + await waitFor((n) => { const sc = document.querySelector('.mp-scroll'); const s = [...sc.children].find((x) => Math.abs(x.offsetTop - sc.scrollTop) < 4); return s && s.getAttribute('data-k').endsWith('/p' + n + '.png'); }, TOTAL - 2, 3000); + const want = 'picture number ' + (TOTAL - 2) + ' '; + await page.keyboard.press('Escape'); + check('the pager closes', await waitFor(() => !document.querySelector('.media-pager') && !!document.querySelector('.notes-feed'), null, 3000)); + const top = () => page.evaluate((w) => { const r = [...document.querySelectorAll('.notes-feed > [data-key]')].find((n) => n.textContent.includes(w)); return r ? Math.round(r.getBoundingClientRect().top) : null; }, want); + await sleep(2500); // the pictures above it load meanwhile + const t = await top(); + check('…the feed sits on the post of the picture last looked at', t !== null && t >= -10 && t < 120, 'row top ' + t); check('no page errors', errs.length === 0, errs.slice(0, 2).join(' | ')); } finally { await browser.close(); server.stop(true); } console.log(ok ? '\n✅ the pager pages the feed on ahead of the reader' : '\n❌ failed'); |
