fix(segments): backport segment-skip fixes from chromecast refactor

Reconcile segment-skip with the diverged-but-ahead version on the
chromecast refactor branch:
- useSegmentSkipper: track auto-skip by segment identity instead of a
  bool, so it no longer re-triggers on pause/unpause; guard skipMode
  "none"; use a finite totalDuration check for Outro.
- Controls: playingRef avoids a stale-closure resume after a seek; only
  resume playback if it was actually playing; skipCredit noop fallback.
- segments: drop the dead try/catch around Promise.allSettled.
- Remove the obsolete useIntroSkipper / useCreditSkipper hooks (177 dead
  lines, superseded by useSegmentSkipper).
This commit is contained in:
Uruk
2026-05-22 01:44:03 +02:00
parent 63ed386369
commit 0990e479d2
5 changed files with 50 additions and 217 deletions

View File

@@ -185,38 +185,31 @@ const fetchLegacySegments = async (
const introSegments: MediaTimeSegment[] = [];
const creditSegments: MediaTimeSegment[] = [];
try {
const [introRes, creditRes] = await Promise.allSettled([
api.axiosInstance.get<IntroTimestamps>(
`${api.basePath}/Episode/${itemId}/IntroTimestamps`,
{ headers: getAuthHeaders(api) },
),
api.axiosInstance.get<CreditTimestamps>(
`${api.basePath}/Episode/${itemId}/Timestamps`,
{ headers: getAuthHeaders(api) },
),
]);
const [introRes, creditRes] = await Promise.allSettled([
api.axiosInstance.get<IntroTimestamps>(
`${api.basePath}/Episode/${itemId}/IntroTimestamps`,
{ headers: getAuthHeaders(api) },
),
api.axiosInstance.get<CreditTimestamps>(
`${api.basePath}/Episode/${itemId}/Timestamps`,
{ headers: getAuthHeaders(api) },
),
]);
if (introRes.status === "fulfilled" && introRes.value.data.Valid) {
introSegments.push({
startTime: introRes.value.data.IntroStart,
endTime: introRes.value.data.IntroEnd,
text: "Intro",
});
}
if (introRes.status === "fulfilled" && introRes.value.data.Valid) {
introSegments.push({
startTime: introRes.value.data.IntroStart,
endTime: introRes.value.data.IntroEnd,
text: "Intro",
});
}
if (
creditRes.status === "fulfilled" &&
creditRes.value.data.Credits.Valid
) {
creditSegments.push({
startTime: creditRes.value.data.Credits.Start,
endTime: creditRes.value.data.Credits.End,
text: "Credits",
});
}
} catch (error) {
console.error("Failed to fetch legacy segments", error);
if (creditRes.status === "fulfilled" && creditRes.value.data.Credits.Valid) {
creditSegments.push({
startTime: creditRes.value.data.Credits.Start,
endTime: creditRes.value.data.Credits.End,
text: "Credits",
});
}
return {