Skip to content

AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.

484 B
Raw Blame
export type EditorCloseGate = {
  closeInFlight: boolean;
  saving: boolean;
  uploading: boolean;
};

export type EditorCloseAction = "block" | "defer" | "run";

/** Decide whether a back/done tap can close now, wait for an in-flight save, or must stay. */
export const resolveEditorCloseAction = ({
  closeInFlight,
  saving,
  uploading,
}: EditorCloseGate): EditorCloseAction => {
  if (uploading) return "block";
  if (saving || closeInFlight) return "defer";
  return "run";
};