Files
t3code/apps/web/src/components/desktopUpdate.toast.tsx
T
8601797233 fix(web): align update toast release notes link (#6322)
Co-authored-by: t3-code[bot] <219304759+t3-code[bot]@users.noreply.github.com>
Co-authored-by: Utkarsh Patil <[email protected]>
Co-authored-by: Exotic <[email protected]>
2026-08-12 14:32:10 -04:00

60 lines
1.6 KiB
TypeScript

import type { DesktopBridge, DesktopUpdateState } from "@t3tools/contracts";
import { ArrowRightIcon } from "lucide-react";
import {
getDesktopUpdateDownloadedVersion,
getDesktopUpdateReleaseUrl,
} from "./desktopUpdate.logic";
import { toastManager } from "./ui/toast";
type DesktopUpdateShell = Pick<DesktopBridge, "openExternal">;
function ReleaseNotesLink({
shell,
releaseUrl,
}: {
shell: DesktopUpdateShell;
releaseUrl: string;
}) {
return (
<button
className="ml-2 inline cursor-pointer text-muted-foreground underline decoration-dotted underline-offset-4 transition-colors hover:text-foreground"
onClick={() => {
void (async () => {
try {
if (await shell.openExternal(releaseUrl)) return;
} catch {
// Surface rejected IPC calls through the same user-visible fallback.
}
toastManager.add({ type: "error", title: "Unable to open release notes" });
})();
}}
type="button"
>
Read more
<ArrowRightIcon
aria-hidden
className="ml-1 inline size-3 -rotate-45 align-[-0.125em]"
strokeWidth={2.25}
/>
</button>
);
}
export function showDesktopUpdateDownloadedToast(
shell: DesktopUpdateShell,
state: DesktopUpdateState,
): void {
const releaseUrl = getDesktopUpdateReleaseUrl(getDesktopUpdateDownloadedVersion(state));
toastManager.add({
type: "success",
title: "Update downloaded",
description: (
<>
Restart the app from the update button to install it.
{releaseUrl ? <ReleaseNotesLink releaseUrl={releaseUrl} shell={shell} /> : null}
</>
),
});
}