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.

1.1 KB
Raw Blame
import { getQueueActivity, type QueueActivity } from '@features/queue/core/queueActivity';
import { getPersonalQueueActivity } from '@features/queue/core/types';

import { useIsProcessorPaused, useQueueCounts } from './queueDataStore';
import { useLoadingModelLabel, useQueueUi } from './QueueUiContext';

/**
 * The queue widget's reading of the shared activity model, from the server's counts of the viewer's own work within the
 * queue scope setting. The top bar and status chip count the same work: the project's runs plus
 * `useQueueOpenWorkElsewhere`.
 */
export const useQueueWidgetActivity = (): {
  activity: QueueActivity;
  inProgress: number;
  loadingModel: string | null;
  pending: number;
} => {
  const { isConnected } = useQueueUi();
  const { inProgress, pending } = getPersonalQueueActivity(useQueueCounts());
  const isPaused = useIsProcessorPaused();
  const loadingModel = useLoadingModelLabel();

  return {
    activity: getQueueActivity({
      hasOpenWork: inProgress + pending > 0,
      isConnected,
      isLoadingModels: loadingModel !== null,
      isPaused,
    }),
    inProgress,
    loadingModel,
    pending,
  };
};