fix(native): clear every episode's pending state and block taps during Mark All

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
jakeandClaude Sonnet 5.5 committed 2026-10-05 13:35:27 -04:00
1 parent 7770e1a697
commit 9209214e98
1 file changed
+14 -10
@@ -102,7 +102,7 @@ export function SeasonAccordion({
const handleEpisodeToggle = useCallback(
(episodeId: string) => {
if (pendingEpisodeIds.has(episodeId)) return;
if (watchSeason.isPending || pendingEpisodeIds.has(episodeId)) return;
setPendingEpisodeIds((prev) => new Set(prev).add(episodeId));
const done = () =>
setPendingEpisodeIds((prev) => {
@@ -111,15 +111,19 @@ export function SeasonAccordion({
return next;
});
const input = { scope: "episode" as const, ids: [episodeId] };
if (watchedEpisodeIds.has(episodeId)) {
unwatchEpisode.mutate(input, { onSettled: done });
} else {
watchEpisode.mutate(input, { onSettled: done });
}
const mutation = watchedEpisodeIds.has(episodeId) ? unwatchEpisode : watchEpisode;
void mutation
.mutateAsync(input)
.catch(() => {
// The mutation's own onError already toasted.
})
.finally(done);
},
[pendingEpisodeIds, watchedEpisodeIds, unwatchEpisode, watchEpisode],
[watchSeason.isPending, pendingEpisodeIds, watchedEpisodeIds, unwatchEpisode, watchEpisode],
);
const anyEpisodePending = pendingEpisodeIds.size > 0;
const seasonNumber = season.seasonNumber;
const episodeCount = episodes.length;
@@ -170,8 +174,8 @@ export function SeasonAccordion({
{watchedCount < episodes.length && (
<Pressable
onPress={() => watchSeason.mutate({ scope: "season", ids: [season.id] })}
disabled={watchSeason.isPending}
accessibilityState={{ disabled: watchSeason.isPending }}
disabled={watchSeason.isPending || anyEpisodePending}
accessibilityState={{ disabled: watchSeason.isPending || anyEpisodePending }}
className="bg-secondary mx-4 mb-2 flex-row items-center justify-center rounded-lg py-2"
>
<Text className="text-title-accent font-sans text-xs font-medium">
@@ -188,7 +192,7 @@ export function SeasonAccordion({
name={episode.name}
airDate={episode.airDate}
isWatched={watchedEpisodeIds.has(episode.id)}
isPending={pendingEpisodeIds.has(episode.id)}
isPending={watchSeason.isPending || pendingEpisodeIds.has(episode.id)}
onToggle={handleEpisodeToggle}
accentColor={titleAccentColor}
mutedColor={mutedFgColor}