diff options
| -rw-r--r-- | src/features/messages.js | 15 | ||||
| -rw-r--r-- | tools/feed-new-posts-test.js | 20 |
2 files changed, 15 insertions, 20 deletions
diff --git a/src/features/messages.js b/src/features/messages.js index 2e3736c..6179404 100644 --- a/src/features/messages.js +++ b/src/features/messages.js @@ -4937,24 +4937,21 @@ export function messagesFeature(ctx) { lastScrollAt = Date.now(); if (!ui.profilePk && (!(ui.chatOpen && ui.msgView === 'feed') || ui.noteThread)) return; windowScrolled(ui.profilePk ? notesCache.get(ui.profilePk) : feed); - // back at the top by yourself: the new posts are under your eyes, so - // the notice has done its job (only the pill repaints — the rows are - // keyed and stay put, so nothing moves under a finger) + // Starting to scroll up dismisses the notice: the reader is already + // heading toward the new posts. Keyed rows keep their positions. // Upward only: holding the page still as posts go in above scrolls it // DOWN, and that must not count as having gone up to look at them. const y = window.scrollY || 0, up = y < lastFeedY; lastFeedY = y; if (!ui.profilePk && Date.now() - lastInputAt < 2500) noteScrollTrail(y); // the reader's own travel (not a held-still insert) - // Scrolling recounts the pill: posts you've gone up past drop off it, - // and once none are left above you the notice is done. + // Keep tracking which posts are ahead, even after hiding the pill. if (!ui.profilePk && feed && feed.ahead?.size && up && !pillFrame) pillFrame = requestAnimationFrame(() => { pillFrame = 0; if (!feed) return; markReached(feed); if (!feed.unseen) return; - const n = pillCount(feed); - if (!n) { feed.unseen = 0; render(); } - else if (n !== feed.pillN) render(); + feed.unseen = 0; + render(); }); if (!ui.profilePk && feed?.deferred?.length) admitFeed(feed.deferred, feed); if (window.innerHeight + window.scrollY < (document.documentElement.scrollHeight || 0) - (ui.profilePk ? 600 : feedLead())) return; @@ -7205,7 +7202,7 @@ export function messagesFeature(ctx) { // The pill's tap: the posts are already in, so this just goes up to them — // to the OLDEST of them, the one right above where you were reading, so - // you read on upward through the rest. Reaching the top by yourself clears + // you read on upward through the rest. Starting to scroll up by yourself clears // the pill too (see the scroll listener). // Drag the new-posts pill any way but up and let go past a short // distance: it flies off that way and onDismiss runs. A short drag springs diff --git a/tools/feed-new-posts-test.js b/tools/feed-new-posts-test.js index 35b8e84..59d6f7c 100644 --- a/tools/feed-new-posts-test.js +++ b/tools/feed-new-posts-test.js @@ -99,21 +99,19 @@ try { assert(!(await page.$('.notes-feed > .row.note-fresh[data-key="'+F(0)+'"]')),'a post barely on screen starts fading too'); await page.evaluate(()=>window.scrollTo(0,0)); await sleep(300); assert.deepEqual(await fresh(),[],'back at the top, the rest fade once seen'); - // Only ever up: reading a new post that's newer than the oldest one, the - // pill counts just the ones above you and the tap goes up to the nearest. + // Starting upward hides the pill before any new post is reached. await test_reset(); await page.evaluate((id)=>{const r=document.querySelector('.notes-feed > [data-key="'+id+'"]');window.scrollTo(0,scrollY+r.getBoundingClientRect().top-100);},reading); await sleep(300); await page.evaluate(()=>test.arrive(3)); await sleep(300); - await page.evaluate((id)=>{const r=document.querySelector('.notes-feed > [data-key="'+id+'"]');window.scrollTo(0,scrollY+r.getBoundingClientRect().top-100);},F(1)); - await sleep(400); - assert.equal(await page.$eval('.feed-new-pill .n',e=>e.textContent),'1','scrolled up past two new posts: one left above'); - const yUp=await page.evaluate(()=>scrollY); - await page.tap('.feed-new-pill'); await sleep(400); - assert(await page.evaluate(()=>scrollY)<yUp,'the tap went up, not down to the oldest new post'); - const newest=await top(F(0)); - assert(newest>=0&&newest<=20,'...landing on the new post above: '+newest); - await page.evaluate(()=>window.scrollTo(0,0)); await sleep(300); + assert(await page.$('.feed-new-pill'),'arrivals show the pill'); + await page.evaluate(()=>window.scrollBy(0,40)); await sleep(300); + assert(await page.$('.feed-new-pill'),'scrolling down leaves the pill visible'); + await page.evaluate(()=>window.scrollBy(0,-10)); await sleep(300); + assert(!(await page.$('.feed-new-pill')),'a small upward scroll hides the pill before reaching new posts'); + assert((await top(F(2)))<0,'new posts are still above the viewport'); + await page.evaluate(()=>{window.scrollBy(0,20);test.render();}); await sleep(300); + assert(!(await page.$('.feed-new-pill')),'scrolling down and repainting do not revive the notice'); // swipe the pill away: it goes, the page doesn't move, and it's back once more arrive await page.evaluate((id)=>{const r=document.querySelector('.notes-feed > [data-key="'+id+'"]');window.scrollTo(0,scrollY+r.getBoundingClientRect().top-100);},reading); await sleep(300); |
