wrolpi/app/src/hooks
lrnselfreliance 83362a65c1
app: video comments and description distinguish pending from empty (#727)
* app: video comments and description distinguish pending from empty

useVideoExtras initialised both values to null and the page treated
null the same as "none", so every video open (and every prev/next)
showed "No comments have been downloaded. Refresh the video?" with a
live Refresh button until the comments arrived.  The Description tab
showed "No description available." the same way.  A failed fetch was
also rendered as "none", and the previous video's data lingered until
the next video's responses arrived.

Invariants now enforced and tested:
* null = pending, undefined = fetch failed, [] / '' = loaded and empty.
  The API serialises a missing info_json field as null, so the hook
  normalises that to empty; consumers never see null for "none".
* Switching video resets both to pending, and a slow response for the
  previous video is dropped.
* The page renders a placeholder while pending, an error message on
  failure, and offers Refresh only once the server confirmed there are
  no comments.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* app: useVideoExtras drops any request that is not the newest

Matching on the video id let a stale request land when the user left
and returned to the same video, or saved an edit while the page's
first description request was still in flight.  Each fetch now takes a
generation number and only the newest generation may write state,
per value, so a description refetch never invalidates a comments
request.

The edit dialog adopts a description that arrives while it is open
only if the user has not typed, so a draft written over the
placeholder is not wiped by the empty or failed value that follows.

Tests: 7 -> none -> 8 -> 7 with the first request rejecting last; a
save refetch beating the initial request; the draft surviving; the
pending placeholder asserted; the console spy restored in finally.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-26 11:22:37 -06:00
..
customHooks.js app: video comments and description distinguish pending from empty (#727) 2026-09-26 11:22:37 -06:00
customHooks.test.js app: video comments and description distinguish pending from empty (#727) 2026-09-26 11:22:37 -06:00
useForm.js ui: a download form that emptied itself after every submit (#665) 2026-08-13 17:14:30 -06:00
useForm.test.js ui: a download form that emptied itself after every submit (#665) 2026-08-13 17:14:30 -06:00
useKeyboardShortcuts.test.js ui: Common.js and thirteen more files off Semantic 2026-08-08 18:04:00 -06:00
useLatestRequest.test.js app: useLatestRequest reports loading before the debounce (#725) 2026-09-25 14:05:08 -06:00
useOverflowNav.js ui: the corner triggers, the More button, and the search modal 2026-08-08 18:05:49 -06:00
useSubsystemToggle.test.js build: uninstall Semantic UI 2026-08-08 18:04:03 -06:00