fix(plex): a collection's failed watched toggle is put back the way it was

C1 moved the optimistic flip onto the key the page reads — and so made visible that nothing corrects
it: the resync only invalidated `plex-library`, so a failed toggle stayed "watched" beside its own
error toast, and the collection's other cached sort orders stayed stale after a good one. The
resync now takes this page's `detail` prefix too, as the Discover and person pages do for theirs.
The C1 test holds the request open, so it still pins the optimistic write on its own.
This commit is contained in:
2026-09-11 03:19:17 +02:00
parent dcd8a9566a
commit d349bc9084
2 changed files with 28 additions and 3 deletions
@@ -165,7 +165,14 @@ export default function PlexCollectionView({
: old,
);
},
resync: () => qc.invalidateQueries({ queryKey: qk.plexLibrary() }),
// This page's OWN key too, not just the library's: the flip above lands on the entry the page
// reads, and resync is what corrects it to the truth when the toggle fails — invalidating only
// `plex-library` left a failed toggle flipped on screen. The prefix (no sort in it) also
// refreshes the other sort orders of this collection cached behind this one.
resync: () => {
qc.invalidateQueries({ queryKey: qk.plexLibrary() });
qc.invalidateQueries({ queryKey: qk.plexCollections("detail", collectionId) });
},
});
async function doRename() {