fix(playlists): an Undo puts a row back after its old neighbour, not at a stale index

A raw index recorded at removal drifted once anything changed before the Undo.
Both lists now read the list fresh and re-insert each row after the row that
preceded it (lib/reinsert). A failed watched toggle in a Plex playlist also
puts the row's state back: its local copy was never re-seeded.
This commit is contained in:
2026-09-27 14:02:15 +02:00
parent b456232d00
commit de62035889
9 changed files with 225 additions and 32 deletions
+4 -2
View File
@@ -7,8 +7,10 @@ import { notifyActionError } from "./actionErrors";
// `resync` (invalidate) — which corrects the optimistic flip to truth either way. Shared by the
// browse grid and the person page, each of which owns a different cache shape.
//
// `revert` is for a cache `resync` must NOT refetch — a random draw (Discover's Surprise rail), which
// a refetch would reshuffle under the viewer. It is called on a failure only, to put the card back.
// `revert` is for state `resync` cannot correct, called on a failure only to put the card back: a
// cache it must NOT refetch — a random draw (Discover's Surprise rail), which a refetch would
// reshuffle under the viewer — or a component's local copy of the rows (a Plex playlist), which an
// identical refetch never re-seeds (react-query keeps the same `data`).
export async function toggleWatchState(
card: PlexCard,
t: TFunction,