From 13eb8152e0c01f3e0de7afa26439c41f0c8dfe09 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Tue, 24 Mar 2026 11:39:58 +0200 Subject: [PATCH] feat(standalone/setup): add syncing steps --- apps/client/src/setup.tsx | 56 ++++++++++++++++--- .../src/translations/en/translation.json | 5 +- 2 files changed, 53 insertions(+), 8 deletions(-) diff --git a/apps/client/src/setup.tsx b/apps/client/src/setup.tsx index 847b489102..db3fc8c569 100644 --- a/apps/client/src/setup.tsx +++ b/apps/client/src/setup.tsx @@ -69,19 +69,61 @@ function SetupOptions({ setState }: { setState: (state: State) => void }) { ); } -function SyncInProgress() { - const { outstandingPullCount, totalPullCount, initialized } = useOutstandingSyncInfo(); +type SyncStep = "connecting" | "syncing" | "finalizing"; - const progress = totalPullCount - ? Math.round(((totalPullCount - outstandingPullCount) / totalPullCount) * 100) +function getSyncStep(stats: { outstandingPullCount: number; totalPullCount: number | null; initialized: boolean }): SyncStep { + if (stats.initialized) { + return "finalizing"; // will reload momentarily + } + if (stats.totalPullCount !== null && stats.outstandingPullCount > 0) { + return "syncing"; + } + if (stats.totalPullCount !== null && stats.outstandingPullCount === 0) { + return "finalizing"; + } + return "connecting"; +} + +function SyncInProgress() { + const stats = useOutstandingSyncInfo(); + const step = getSyncStep(stats); + + useEffect(() => { + if (stats.initialized) { + location.reload(); + } + }, [stats.initialized]); + + const steps: { key: SyncStep; label: string }[] = [ + { key: "connecting", label: t("setup.sync-step-connecting") }, + { key: "syncing", label: t("setup.sync-step-syncing") }, + { key: "finalizing", label: t("setup.sync-step-finalizing") } + ]; + + const currentIndex = steps.findIndex((s) => s.key === step); + + const progress = stats.totalPullCount + ? Math.round(((stats.totalPullCount - stats.outstandingPullCount) / stats.totalPullCount) * 100) : 0; return (

{t("setup.sync-in-progress-title")}

-

{t("setup.sync-in-progress-description")}

- -

{progress}% ({totalPullCount ? totalPullCount - outstandingPullCount : 0} / {totalPullCount ?? "?"})

+ +
    + {steps.map((s, i) => ( +
  1. + {" "} + {s.label} + {s.key === "syncing" && step === "syncing" && ( +
    + + {progress}% +
    + )} +
  2. + ))} +
); } diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json index 8777665bbd..7d768178cc 100644 --- a/apps/client/src/translations/en/translation.json +++ b/apps/client/src/translations/en/translation.json @@ -2249,6 +2249,9 @@ "sync-in-progress-description": "Your device is now connected and items are being synchronized.", "password-placeholder": "Password", "button-back": "Back", - "button-finish-setup": "Finish setup" + "button-finish-setup": "Finish setup", + "sync-step-connecting": "Connecting to server", + "sync-step-syncing": "Syncing data", + "sync-step-finalizing": "Setting up options" } }