diff options
| -rw-r--r-- | src/features/messages.js | 7 | ||||
| -rw-r--r-- | tools/profile-pager-test.js | 7 |
2 files changed, 9 insertions, 5 deletions
diff --git a/src/features/messages.js b/src/features/messages.js index ccba6ad..c568ae0 100644 --- a/src/features/messages.js +++ b/src/features/messages.js @@ -12588,9 +12588,10 @@ export function messagesFeature(ctx) { } function pagerPosition() { if (!pager) return; - const slides = pagerSlides(); - const index = slides.indexOf(pager.cur || pager.anchor); - pager.el.querySelector('.mp-position').textContent = (index < 0 ? 0 : index + 1) + ' / ' + slides.length; + const groups = pagerGroups(); + const slide = pager.cur || pager.anchor; + const index = groups.indexOf(slide && slide.closest('.mp-group')); + pager.el.querySelector('.mp-position').textContent = (index < 0 ? 0 : index + 1) + ' / ' + groups.length; } function buildPager(want) { diff --git a/tools/profile-pager-test.js b/tools/profile-pager-test.js index 2835b34..85aee86 100644 --- a/tools/profile-pager-test.js +++ b/tools/profile-pager-test.js @@ -94,19 +94,22 @@ try { check('her picture opens in the pager, on itself', await resting('a1.png'), await curPic()); const keys = await page.evaluate(() => [...document.querySelectorAll('.mp-slide')].map((s) => s.getAttribute('data-k').split('/').pop())); check('the pager holds her pictures only, in her timeline\'s order', JSON.stringify(keys) === JSON.stringify(['a1.png', 'a2.png', 'b.png', 'd.png']), JSON.stringify(keys)); + check('counter starts at the first post', await page.$eval('.mp-position', (e) => e.textContent) === '1 / 3'); await page.keyboard.press('ArrowRight'); check('right: the post\'s second picture', await resting('a2.png'), await curPic()); + check('sideways keeps the same post number', await page.$eval('.mp-position', (e) => e.textContent) === '1 / 3'); await page.keyboard.press('ArrowDown'); check('down: her next post with a picture', await resting('b.png'), await curPic()); + check('down advances by one post', await page.$eval('.mp-position', (e) => e.textContent) === '2 / 3'); await page.keyboard.press('ArrowDown'); check('down again: her last', await resting('d.png'), await curPic()); await page.keyboard.press('ArrowDown'); await sleep(600); check('past her last wraps to her first post', await resting('a2.png'), await curPic()); - check('counter follows sideways position', await page.$eval('.mp-position', (e) => e.textContent) === '2 / 4'); + check('counter counts the first post once', await page.$eval('.mp-position', (e) => e.textContent) === '1 / 3'); check('no loading slide', await page.$('.mp-tail') === null); await page.keyboard.press('ArrowUp'); await resting('d.png'); check('up from first wraps to last', await curPic() === 'd.png'); - check('counter at the last picture', await page.$eval('.mp-position', (e) => e.textContent) === '4 / 4'); + check('counter at the last post', await page.$eval('.mp-position', (e) => e.textContent) === '3 / 3'); await page.touchscreen.touchStart(195, 650); for (let i = 1; i <= 8; i++) { await page.touchscreen.touchMove(195, 650 - 40 * i); await sleep(16); } await page.touchscreen.touchEnd(); |
