Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

949 B
Raw Blame
import React, {
  createContext,
  useContext,
  useState,
  ReactNode,
} from "react";

interface ChangelogDialogContextType {
  showChangelogDialog: boolean;
  setShowChangelogDialog: (show: boolean) => void;
}

const ChangelogDialogContext = createContext<
  ChangelogDialogContextType | undefined
>(undefined);

export const ChangelogDialogProvider: React.FC<{ children: ReactNode }> = ({
  children,
}) => {
  const [showChangelogDialog, setShowChangelogDialog] = useState(false);

  return (
    <ChangelogDialogContext.Provider
      value={{ showChangelogDialog, setShowChangelogDialog }}
    >
      {children}
    </ChangelogDialogContext.Provider>
  );
};

export const useChangelogDialog = (): ChangelogDialogContextType => {
  const context = useContext(ChangelogDialogContext);
  if (context === undefined) {
    throw new Error(
      "useChangelogDialog must be used within a ChangelogDialogProvider"
    );
  }
  return context;
};