Skip to content

armgit / uzu

Public Imported from GitHub
0

A high-performance inference engine for AI models

906 B
Raw Blame
import { UpdateToast } from "@/components/update-toast";
import { toast } from "react-hot-toast";

const toastPosition = "top-right" as const;

type ReadyToastParams = {
  version: string;
  toastId: string;
  onApplyNow: () => void | Promise<void>;
  onLater: () => void | Promise<void>;
  errorMessage?: string;
};

export const dismissUpdateToast = (toastId: string): void => {
  toast.dismiss(toastId);
};

export const showReadyUpdateToast = ({
  version,
  toastId,
  onApplyNow,
  onLater,
  errorMessage,
}: ReadyToastParams): void => {
  toast.custom(
    (t) => (
      <UpdateToast
        visible={t.visible}
        version={version}
        onApplyNow={onApplyNow}
        onLater={onLater}
        errorMessage={errorMessage}
        onClose={() => dismissUpdateToast(toastId)}
      />
    ),
    {
      id: toastId,
      position: toastPosition,
      duration: Infinity,
    },
  );
};