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( const handleEpisodeToggle = useCallback(
(episodeId: string) => { (episodeId: string) => {
if (pendingEpisodeIds.has(episodeId)) return; if (watchSeason.isPending || pendingEpisodeIds.has(episodeId)) return;
setPendingEpisodeIds((prev) => new Set(prev).add(episodeId)); setPendingEpisodeIds((prev) => new Set(prev).add(episodeId));
const done = () => const done = () =>
setPendingEpisodeIds((prev) => { setPendingEpisodeIds((prev) => {
@@ -111,15 +111,19 @@ export function SeasonAccordion({
return next; return next;
}); });
const input = { scope: "episode" as const, ids: [episodeId] }; const input = { scope: "episode" as const, ids: [episodeId] };
if (watchedEpisodeIds.has(episodeId)) { const mutation = watchedEpisodeIds.has(episodeId) ? unwatchEpisode : watchEpisode;
unwatchEpisode.mutate(input, { onSettled: done }); void mutation
} else { .mutateAsync(input)
watchEpisode.mutate(input, { onSettled: done }); .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 seasonNumber = season.seasonNumber;
const episodeCount = episodes.length; const episodeCount = episodes.length;
@@ -170,8 +174,8 @@ export function SeasonAccordion({
{watchedCount < episodes.length && ( {watchedCount < episodes.length && (
<Pressable <Pressable
onPress={() => watchSeason.mutate({ scope: "season", ids: [season.id] })} onPress={() => watchSeason.mutate({ scope: "season", ids: [season.id] })}
disabled={watchSeason.isPending} disabled={watchSeason.isPending || anyEpisodePending}
accessibilityState={{ disabled: watchSeason.isPending }} accessibilityState={{ disabled: watchSeason.isPending || anyEpisodePending }}
className="bg-secondary mx-4 mb-2 flex-row items-center justify-center rounded-lg py-2" 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"> <Text className="text-title-accent font-sans text-xs font-medium">
@@ -188,7 +192,7 @@ export function SeasonAccordion({
name={episode.name} name={episode.name}
airDate={episode.airDate} airDate={episode.airDate}
isWatched={watchedEpisodeIds.has(episode.id)} isWatched={watchedEpisodeIds.has(episode.id)}
isPending={pendingEpisodeIds.has(episode.id)} isPending={watchSeason.isPending || pendingEpisodeIds.has(episode.id)}
onToggle={handleEpisodeToggle} onToggle={handleEpisodeToggle}
accentColor={titleAccentColor} accentColor={titleAccentColor}
mutedColor={mutedFgColor} mutedColor={mutedFgColor}