Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

938 B
Raw Blame
export type TextSessionStatus = 'idle' | 'pending' | 'editing' | 'committed';
type TextSessionEvent = 'BEGIN' | 'EDIT' | 'COMMIT' | 'CANCEL';

export const transitionTextSessionStatus = (status: TextSessionStatus, event: TextSessionEvent): TextSessionStatus => {
  switch (status) {
    case 'idle':
      if (event === 'BEGIN') {
        return 'pending';
      }
      return status;
    case 'pending':
      if (event === 'EDIT') {
        return 'editing';
      }
      if (event === 'CANCEL') {
        return 'idle';
      }
      return status;
    case 'editing':
      if (event === 'COMMIT') {
        return 'committed';
      }
      if (event === 'CANCEL') {
        return 'idle';
      }
      return status;
    case 'committed':
      if (event === 'BEGIN') {
        return 'pending';
      }
      if (event === 'CANCEL') {
        return 'idle';
      }
      return status;
    default:
      return status;
  }
};