返回 CodeWhale
feed-retry.tsx
根目录 / web / components / feed-retry.tsx
1 "use client";
2
3 import { useRouter } from "next/navigation";
4 import { RetryAction } from "@/components/retry-action";
5
6 /**
7 * The feed page's retry. `/feed` is ISR (600s), so a bare server re-render
8 * would serve the same cached `skipped`/`unavailable` record the visitor is
9 * looking at; POST to the retry endpoint first to bust the cached route,
10 * then refresh so the server render happens against fresh data.
11 */
12 export function FeedRetry({ label }: { label: string }) {
13 const router = useRouter();
14 return (
15 <RetryAction
16 label={label}
17 onRetry={async () => {
18 try {
19 await fetch("/api/github/feed/retry", { method: "POST", cache: "no-store" });
20 } catch {
21 // Offline or unreachable: the refresh below is still the real
22 // retry signal; a rejected POST must not escape to RetryAction.
23 } finally {
24 router.refresh();
25 }
26 }}
27 />
28 );
29 }
30
30 lines Plain Text