Catch the feed list up when the page comes back into view (#168)
All Subscriptions said 1 unread when the server had none. The badge is the page's own sum of its feed list, loaded once and patched only by events the server sends when a scan or a download changes a feed. Reading an item, marking everything read or unsubscribing sends none, so another device's page kept its old counts, and an iPhone stops the event stream while the app is in the background, missing everything meanwhile; the reconnect did not catch up. The page now takes the feed list and the open list again when it comes back into view and when the stream reconnects after a drop. A browser test reads an item behind the page's back and checks the badge follows once the page is shown again; it fails without this. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1683,3 +1683,21 @@ test.describe('on a narrow phone', () => {
|
||||
await page.evaluate(() => setTheme('modern', 'dark'));
|
||||
});
|
||||
});
|
||||
|
||||
test('a page brought back into view catches up with what was read elsewhere', async ({ page }) => {
|
||||
// Reading an item tells no other page, and a phone's page misses everything while it is in the
|
||||
// background: All Subscriptions went on counting an item read elsewhere as unread (#168).
|
||||
const badge = page.locator('.place[data-id=":all"] .badge');
|
||||
const [one] = (await (await page.request.get('/api/entries?limit=1')).json()).entries;
|
||||
const flag = read => page.request.post(`/api/entries/${encodeURIComponent(one.feed_id)}/${encodeURIComponent(one.guid)}/flags`, { data: { read } });
|
||||
await flag(false);
|
||||
await page.reload();
|
||||
const before = Number(await badge.textContent());
|
||||
expect(before).toBeGreaterThan(0);
|
||||
await flag(true); // read on another device
|
||||
await page.evaluate(() => {
|
||||
Object.defineProperty(document, 'hidden', { configurable: true, get: () => false });
|
||||
document.dispatchEvent(new Event('visibilitychange'));
|
||||
});
|
||||
await expect(badge).toHaveText(String(before - 1));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user