Fix DM thread paging: scope the direction filter under the cursor #3
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/dm-thread-paging-precedence"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
The direct-message thread endpoint could make a client scroll forever with just a spinner when loading older messages.
Cause
All three branches of
DirectMessageController::thread()filter the two directions of a conversation with a top-level->where(...)->orWhere(...):which SQL reads as
(id < max_id AND their→you) OR (you→them). TheorWhereescapes the cursor, so the requesting user’s own sent messages ignoremax_idand come back in full on every page. A client paging back through a thread with ≥8 sent messages receives the same 8 each call, dedupes them to zero new, never advances the cursor, and spins indefinitely.Verified live against scatto.social:
max_id=52returned messages124,121,120,52,51— the124/121/120are own-messages newer than the cursor, bypassing it.Fix
Wrap the two-direction test in a single nested closure so the cursor scopes the whole thing:
id < max_id AND ((their→you) OR (you→them)). Applied to both themax_id(older) andmin_id(newer) branches. The no-cursorelsebranch has noidfilter to escape and is left unchanged.Client side
Scatto 2.9.6 also gained a guard (a page that adds nothing new ends paging) so it survives an unfixed server without the infinite spinner, but that only masks the symptom — this is the actual fix, and restores full older-message paging.
Pull request closed