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.

733 B
Raw Blame
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
import { selectSearchTerm } from 'features/gallery/store/gallerySelectors';
import { searchTermChanged } from 'features/gallery/store/gallerySlice';
import { useCallback } from 'react';

export const useGallerySearchTerm = () => {
  // Highlander!
  // useAssertSingleton('gallery-search-state');

  const dispatch = useAppDispatch();
  const searchTerm = useAppSelector(selectSearchTerm);

  const onChange = useCallback(
    (val: string) => {
      dispatch(searchTermChanged(val));
    },
    [dispatch]
  );

  const onReset = useCallback(() => {
    dispatch(searchTermChanged(''));
  }, [dispatch]);

  return [searchTerm, onChange, onReset] as const;
};