A short Unread list read through no longer says more to load (#385)

hasMore() compared nextOffset(), which on Unread counts only the loaded
items still unread, with S.total from the answer: once they were read it
was 0 against that total, so the page asked for a page that came back
empty and took its total, 0, with the items still on screen. Whether
more is left now comes from the last answer itself, its offset and items
against its total; reading takes an item off the server's list and off
nextOffset() alike, so what that answer said is left stays true.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-06 23:44:51 +00:00
parent 8a66f9c7ee
commit d3b8c4cd01
5 changed files with 17 additions and 3 deletions

View File

@@ -104,6 +104,9 @@ async function loadEntries(append?: boolean, quiet?: boolean){
/// A list's page into S and onto the screen.
function showList(r: ListPage, append: boolean, asked: number){
S.total=r.total;
// Reading an item takes it off the server's Unread list and off nextOffset() alike, so what is
// left there stays as this answer says; S.total against nextOffset() said more once read (#385).
S.more=(append?S.offset:0)+r.entries.length<r.total;
for(const e of r.entries){
const w=readWrites.get(entryKey(e));
if(w && !(w.done!==undefined&&w.done<asked)) e.read=w.read;
@@ -325,7 +328,7 @@ function selectEntry(e: Entry,turning=false){
/// Where the next page starts. On the Unread tab the items read here are no longer unread on the
/// server, so counting them, as a flat 50 a page did, skipped as many unread ones.
function nextOffset(){ return S.filter==='unread' ? S.entries.filter(e=>!e.read).length : S.entries.length; }
const hasMore=()=>nextOffset()<S.total;
const hasMore=()=>S.more;
/// Turning near the end of what is loaded fetches the next page behind: only the list's Load more
/// button did, and a swipe or j stopped dead at the 50th item until a reload (#383).
let loadingAhead=false;