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.0 KB
Raw Blame
import { useStore } from '@nanostores/react';
import { createSelector } from '@reduxjs/toolkit';
import { useAppSelector } from 'app/store/storeHooks';
import { $templates } from 'features/nodes/store/nodesSlice';
import { selectNodes } from 'features/nodes/store/selectors';
import { isInvocationNode } from 'features/nodes/types/invocation';
import { getNeedsUpdate } from 'features/nodes/util/node/nodeUpdate';
import { useMemo } from 'react';

export const useGetNodesNeedUpdate = () => {
  const templates = useStore($templates);
  const selector = useMemo(
    () =>
      createSelector(selectNodes, (nodes) =>
        nodes.some((node) => {
          if (!isInvocationNode(node)) {
            return false; // Invocation nodes do not need updates
          }
          const template = templates[node.data.type];
          if (!template) {
            return false;
          }
          return getNeedsUpdate(node.data, template);
        })
      ),
    [templates]
  );
  const needsUpdate = useAppSelector(selector);
  return needsUpdate;
};