fix(feed): a reset clears the card's resume position at once, not only its status

The optimistic layer overrode only the status, so after "Reset — clear watch progress/status" the
card kept its progress bar and its Continue button until the next refetch. Found in the E28 S3e1
UAT.
This commit is contained in:
2026-09-26 01:23:44 +02:00
parent fa0b0edd63
commit 9d7526ee57
2 changed files with 119 additions and 0 deletions
+12
View File
@@ -145,6 +145,9 @@ export default function Feed({
: SORT_KEYS;
const [overrides, setOverrides] = useState<Record<string, VideoStatus>>({});
const [savedOverrides, setSavedOverrides] = useState<Record<string, boolean>>({});
// A reset drops the resume position too, which a status override cannot say: without this the card
// kept its progress bar and its Continue button until the next refetch.
const [resetIds, setResetIds] = useState<Record<string, true>>({});
// The open player: which video and where to start (null = resume from saved position).
const [activeVideo, setActiveVideo] = useState<{ video: Video; startAt: number | null } | null>(
null,
@@ -238,6 +241,7 @@ export default function Feed({
setOverridesFor(filters);
setOverrides({});
setSavedOverrides({});
setResetIds({});
}
// ...but NOT on infinite-scroll appends: fetchNextPage also bumps dataUpdatedAt while page 1's
// rows are unchanged, so clearing overrides there would make a just-hidden card flash back.
@@ -250,6 +254,7 @@ export default function Feed({
if (!appended) {
setOverrides({});
setSavedOverrides({});
setResetIds({});
}
}, [query.dataUpdatedAt, pagesLen]);
@@ -350,6 +355,7 @@ export default function Feed({
// Reset to pristine (drop the whole VideoState row, incl. resume position) — the
// un-watch toggle can't clear an in-progress position, this can.
setOverrides((o) => ({ ...o, [id]: "new" }));
setResetIds((r) => ({ ...r, [id]: true }));
api
.clearState(id)
// Stale-mark only (see setState above): the optimistic override already reset the card.
@@ -361,6 +367,11 @@ export default function Feed({
delete next[id];
return next;
});
setResetIds((r) => {
const next = { ...r };
delete next[id];
return next;
});
});
},
[qc],
@@ -395,6 +406,7 @@ export default function Feed({
const status = overrides[v.id]; // read once so the narrowing sticks
return status ? { ...v, status } : v;
})
.map((v) => (resetIds[v.id] ? { ...v, position_seconds: 0 } : v))
.map((v) => {
const saved = savedOverrides[v.id];
return saved !== undefined ? { ...v, saved } : v;