Skip to content

Commit 1c56ae7

Browse files
author
rsi-pr-agent
committed
fixup! fix(web): show server update progress through reconnect (#1713)
Fork-Domain: upstream-fixes Fork-Tier: bugfix Fork-Upstreamable: yes
1 parent 9d58690 commit 1c56ae7

2 files changed

Lines changed: 14 additions & 8 deletions

File tree

‎apps/web/src/components/ServerUpdateAction.tsx‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import {
2424
} from "@t3tools/client-runtime/state/runtime";
2525
import { CircleArrowUpIcon } from "lucide-react";
2626
import { type ComponentProps, useRef, useState } from "react";
27-
import { useEffect } from "react"; // fork-hook: upstream-fixes/server-update-progress-clock
27+
import { useServerUpdateClockFork } from "./serverUpdateClock.fork"; // fork-hook: upstream-fixes/server-update-progress-clock
2828

2929
import { requestConfirmDialog } from "~/confirmDialog";
3030
import { useCopyToClipboard } from "~/hooks/useCopyToClipboard";
@@ -205,13 +205,7 @@ function useServerUpdateDetail(state: Exclude<ServerUpdateState, { status: "idle
205205
state.status === "running" &&
206206
state.stage === "resuming" &&
207207
state.restartStartedAt !== undefined;
208-
const [now, setNow] = useState(Date.now);
209-
// oxlint-disable-next-line t3code/react-effect-budget -- A wall clock ticks the restart. // fork-hook: upstream-fixes/server-update-progress-clock
210-
useEffect(() => {
211-
if (!ticking) return;
212-
const timer = setInterval(() => setNow(Date.now()), 1000);
213-
return () => clearInterval(timer);
214-
}, [ticking]);
208+
const now = useServerUpdateClockFork(ticking); // fork-hook: upstream-fixes/server-update-progress-clock
215209
if (state.status === "failed") return state.message;
216210
if (state.status === "completed") return `Updated to t3@${state.targetVersion}.`;
217211
const elapsed = serverUpdateRestartElapsedSeconds(state, now);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { useEffect, useState } from "react";
2+
3+
export function useServerUpdateClockFork(ticking: boolean) {
4+
const [now, setNow] = useState(Date.now);
5+
// oxlint-disable-next-line t3code/no-unreasoned-state-sync -- A wall clock ticks the restart while the transport is reconnecting.
6+
useEffect(() => {
7+
if (!ticking) return;
8+
const timer = setInterval(() => setNow(Date.now()), 1000);
9+
return () => clearInterval(timer);
10+
}, [ticking]);
11+
return now;
12+
}

0 commit comments

Comments
 (0)