fix(web): complete fast update check rotation
Co-authored-by: Wout Stiens <[email protected]>
This commit is contained in:
1 parent
b73232bdd3
commit
2cc713b3b3
4 files changed
+33
-3
No files matched your search
@@ -0,0 +1,7 @@
|
||||
import { RefreshCwIcon } from "lucide-react";
|
||||
|
||||
import { cn } from "../../lib/utils";
|
||||
|
||||
export function DesktopUpdateCheckIcon({ isAnimating }: { readonly isAnimating: boolean }) {
|
||||
return <RefreshCwIcon className={cn("size-4", isAnimating && "animate-spin-once")} />;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { renderToStaticMarkup } from "react-dom/server";
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import { DesktopUpdateCheckIcon } from "./DesktopUpdateCheckIcon";
|
||||
|
||||
describe("DesktopUpdateCheckIcon", () => {
|
||||
it("keeps the refresh icon spinning while a fast update check settles", () => {
|
||||
const markup = renderToStaticMarkup(<DesktopUpdateCheckIcon isAnimating />);
|
||||
|
||||
expect(markup).toContain("animate-spin-once");
|
||||
});
|
||||
|
||||
it("does not animate while idle", () => {
|
||||
const markup = renderToStaticMarkup(<DesktopUpdateCheckIcon isAnimating={false} />);
|
||||
|
||||
expect(markup).not.toContain("animate-spin-once");
|
||||
});
|
||||
});
|
||||
@@ -1,4 +1,4 @@
|
||||
import { DownloadIcon, RefreshCwIcon, RotateCwIcon, TriangleAlertIcon } from "lucide-react";
|
||||
import { DownloadIcon, RotateCwIcon, TriangleAlertIcon } from "lucide-react";
|
||||
import { useCallback, useState } from "react";
|
||||
import { isElectron } from "../../env";
|
||||
import { cn } from "../../lib/utils";
|
||||
@@ -21,6 +21,7 @@ import { Alert, AlertDescription, AlertTitle } from "../ui/alert";
|
||||
import { Separator } from "../ui/separator";
|
||||
import { SidebarMenuItem } from "../ui/sidebar";
|
||||
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
|
||||
import { DesktopUpdateCheckIcon } from "./DesktopUpdateCheckIcon";
|
||||
|
||||
function keyReleaseNoteItems(items: ReadonlyArray<string>) {
|
||||
const occurrences = new Map<string, number>();
|
||||
@@ -110,6 +111,7 @@ export function SidebarUpdatePill() {
|
||||
function SidebarUpdateControl() {
|
||||
const state = useDesktopUpdateState();
|
||||
const [isActionPending, setIsActionPending] = useState(false);
|
||||
const [checkAnimationKey, setCheckAnimationKey] = useState(0);
|
||||
|
||||
const action = state ? resolveDesktopUpdateButtonAction(state) : "none";
|
||||
const isDownloading = state?.status === "downloading";
|
||||
@@ -209,6 +211,7 @@ function SidebarUpdateControl() {
|
||||
return;
|
||||
}
|
||||
|
||||
setCheckAnimationKey((key) => key + 1);
|
||||
void bridge
|
||||
.checkForUpdate()
|
||||
.then((result) => {
|
||||
@@ -257,8 +260,9 @@ function SidebarUpdateControl() {
|
||||
) : isUpdateState ? (
|
||||
<DownloadIcon className="size-4" />
|
||||
) : (
|
||||
<RefreshCwIcon
|
||||
className={cn("size-4", state?.status === "checking" && "animate-spin")}
|
||||
<DesktopUpdateCheckIcon
|
||||
key={checkAnimationKey}
|
||||
isAnimating={checkAnimationKey > 0 || state?.status === "checking"}
|
||||
/>
|
||||
)}
|
||||
</button>
|
||||
|
||||
@@ -140,6 +140,7 @@ html[data-mobile-composer-route-transition="true"]::view-transition-old(t3-mobil
|
||||
}
|
||||
|
||||
@theme inline {
|
||||
--animate-spin-once: spin 1s linear 1;
|
||||
--color-zinc-25: oklch(99.2% 0 0);
|
||||
--animate-skeleton: skeleton 2s infinite linear;
|
||||
/* Duty-cycled indicator animations: long holds with stepped ramps, so the
|
||||
|
||||
Reference in new issue
Block a user